The pivot table visualization aggregates records from a query result into a new tabular display. It’s similar to
GROUP BY statements in SQL. You configure the pivot table visualization with drag-and-drop fields instead of SQL code.
If your query result is too large pivot table performance can degrade. The exact size threshold will depend on the computer and browser from which you access Databricks SQL. In general, performance is best with at most 50,000 fields. That could mean 10,000 records with 5 fields each. Or 1,000 records with 50 fields each.
The query for a pivot table should return at least three columns. The source query for a pivot table is usually non-aggregated or “melted”.
The following example shows mock data from a school grading system. The query doesn’t group or sort the data.
Create a pivot table visualization
Click + Add Visualization.
In the Visualization Type drop-down, select Pivot Table. The visualization preview on the right updates to show a pivot table.
All the field aliases from your query result become available at the top of the pivot control surface. You can drag these to the row side or the column side. You can also nest them.
Here are some examples using the grade data:
Edit a visualization
To edit a visualization, click its tab on the tab bar, then click the Edit Visualization button beneath the visualization.
Temporarily hide or show only a series
To hide a series in a visualization, click the series in the legend. To show the series again, click it again in the legend.
To show only a single series, double-click the series in the legend. To show other series, click each one.
Submit and view feedback for