Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(bi): render saved pivot results on dashboards (#127793)

Marius Andra4ffbe6e2ea37
diff --git a/docs/published/handbook/engineering/data-warehouse.md b/docs/published/handbook/engineering/data-warehouse.md
index 3467e59677b2..45043b7e102b 100644
--- a/docs/published/handbook/engineering/data-warehouse.md
+++ b/docs/published/handbook/engineering/data-warehouse.md
@@ -131,6 +131,9 @@ The **Marks** card offers table calculations per measure: percent of total, runn
**Table** automatically uses a pivot layout when **Columns** contains dimensions, including when **Rows** contains only measures. Row members run down the table; column members run across it. Measures placed on **Rows** appear vertically, and measures placed on **Columns** appear beneath each column header. Measures split between both shelves appear as columns with guidance to place them together. Move all dimensions onto **Rows** to return to a flat table. Period comparisons keep their comparison table layout. Direct database connections keep the flat table layout. Large pivots virtualize rows and columns while retaining grouped headers and the sticky row labels. Pivots support up to 10,000 measure columns and 100,000 displayed rows, including measures on Rows. Larger results ask you to reduce dimensions or measures, or use Top N. Text-valued custom aggregates retain their values. The explicit **Pivot table** chart uses the same pivot layout. Expand or collapse a row or column header to move between hierarchy levels. Collapsed values are reaggregated from source rows, including averages and distinct counts. **Subtotals** also shows the intermediate aggregates while expanded. Row and column grand totals retain their separate controls, and total cells keep drill-down scoped to the visible dimensions. Expansion is local to the view; the worksheet's shelves and settings remain unchanged. Tracking records hierarchy expansion with axis and depth, and adds missing-date and full-window settings to the existing worksheet events.
+Saved BI pivot tables display their results on dashboards, including tiles that ignore dashboard filters.
+Dashboard tiles preserve the worksheet's column groups and measure placement.
+
**Hierarchies** in the data pane names an ordered set of dimensions, such as Country → State → City. Create a hierarchy with 2–10 levels, then start it on rows or columns. The level list marks the current field and shows the next levels. Selecting a result offers **Drill to** the next level in the current editor worksheet, retaining parent filters, date range, measures, variables, and formatting. The path above the result offers **Drill up**, removing only filters introduced by that drill. Navigation participates in undo/redo and respects Auto update. Changed or removed hierarchy levels disable an incompatible return path. Outside the editor, the action explicitly opens a new worksheet. Leaf values and levels already on a shelf do not offer another drill action; nested pivot expansion remains available for those shelves. Definitions stay with the saved worksheet and survive **Clear sheet**. **Import from worksheet** copies a hierarchy from an accessible saved worksheet using the same table and connection. The copy is independent: edits do not change the source worksheet or create global fields. Deleting a local calculated field removes its uses from hierarchy levels, dropping definitions with fewer than two remaining levels.
The **Analysis** card ranks **Top N** categories by a selected measure across the full current date range. **Include "Other"** combines the remaining source rows and re-aggregates them, including averages and distinct counts. Removing the ranking measure turns Top N off. Previous-period comparisons use the current period's category selection. Tables offer a grand total; pivot tables offer row and column grand totals. Both support hierarchy subtotals when an axis has multiple dimensions. Totals re-aggregate source rows; table-calculation cells remain blank on total rows. Summary rows can occupy at most half the result limit, reserving room for detail cells. The BI visualization requests an extra row to determine whether more results exist, then removes it before building tables and charts. Saved SQL and exports retain the worksheet's configured limit. A notice identifies confirmed extra groups. New worksheets default to 50,000 aggregated rows. At the 50,000-row execution cap, it instead says more groups may exist because the extra-row probe cannot complete. The **Aggregated rows** limit applies after aggregation, not to scanned source rows. Limited results can make totals, rankings, running totals, and comparisons incomplete; narrow filters or increase the limit where possible.
diff --git a/products/business_intelligence/frontend/biQueryResults.test.ts b/products/business_intelligence/frontend/biQueryResults.test.ts
index 4afd9af9d712..bfec7b46100a 100644
--- a/products/business_intelligence/frontend/biQueryResults.test.ts
+++ b/products/business_intelligence/frontend/biQueryResults.test.ts
@@ -27,6 +27,35 @@ const node = (config: BIConfig): BIVisualizationNode => ({
})
describe('BI visualization data reuse', () => {
+ test.each(['result', 'results'] as const)(
+ 'renders saved pivot data from %s and applies the row limit',
+ (resultKey) => {
+ const query = node({ ...config, chartType: ChartDisplayType.ActionsTable, rows: [], limit: 100 })
+ const columns = [...getBIResultDimensions(query.config).map(({ column }) => column), 'sum_revenue']
+ const rows = Array.from({ length: 101 }, (_, index) => [`category ${index}`, index])
+ const response = {
+ columns,
+ types: columns.map((column, index) => [column, index === 0 ? 'String' : 'Float64']),
+ [resultKey]: rows,
+ last_refresh: '2026-10-01T00:00:00Z',
+ }
+ const original = structuredClone(response)
+ expect(getBIVisualizationResponse(query, response)).toMatchObject({
+ columns,
+ types: response.types,
+ results: rows.slice(0, 100),
+ hasMore: true,
+ last_refresh: response.last_refresh,
+ })
+ expect(getBIResultSummary(query, response)).toMatchObject({ groups: 100, marks: 100, limited: true })
+ expect(response).toEqual(original)
+ expect(getBIVisualizationResponse(query, { ...response, [resultKey]: [] })).toMatchObject({
+ results: [],
+ hasMore: false,
+ })
+ }
+ )
+
test.each([
ChartDisplayType.ScatterPlot,
ChartDisplayType.ActionsLineGraph,
diff --git a/products/business_intelligence/frontend/biQueryResults.ts b/products/business_intelligence/frontend/biQueryResults.ts
index 93a7d3026488..9d2420f77425 100644
--- a/products/business_intelligence/frontend/biQueryResults.ts
+++ b/products/business_intelligence/frontend/biQueryResults.ts
@@ -72,12 +72,13 @@ export function getBIVisualizationResponse(
query: VisualizationNode,
response: AnyResponseType | null
): AnyResponseType | null {
- if (
- query.kind !== NodeKind.BIVisualizationNode ||
- !response ||
- !('results' in response) ||
- !Array.isArray(response.results)
- ) {
+ if (query.kind !== NodeKind.BIVisualizationNode || !response) {
+ return response
+ }
+ if (!('results' in response) && 'result' in response && Array.isArray(response.result)) {
+ response = { ...response, results: response.result }
+ }
+ if (!('results' in response) || !Array.isArray(response.results)) {
return response
}
const dataConfig = getBIDataConfig(query.config)