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(insights): show compare period tag in detailed results with breakdowns (#70446)

Thomas Obermüllerec605fac62b8
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 9f274ac72978..d43022998558 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -2708,6 +2708,10 @@ snapshots:
hash: v1.k794b7964.41fb69aabc8a918c58f693db54ee71abf53115782820dd01a1a26f6929dbe714.ACZOSkxt8vlxz5dr0DPoe7koXbe7aUxWeHcU4zMhv84
insights-insightstable--compare-previous--light:
hash: v1.k794b7964.28fa002817466cdc38906e70bc568a02c9d4080d4e696ec4013a2a538907b56d.yFhGtvxHTdLkBaBTudbBvH9CQbI3uANS3b2ycEIeKRY
+ insights-insightstable--compare-previous-detailed-results--dark:
+ hash: v1.k794b7964.a64b2e50f805705bbc9b8d2ebd207cebcd1202dc578004ab1e9dc477f02ff9aa.E8oFRn7xnK_56vtfgxYZuC1XNdTAUAc-aRld_poFGNk
+ insights-insightstable--compare-previous-detailed-results--light:
+ hash: v1.k794b7964.95d186cac16aa659249c098d76264c71a4f75af27fe8ddc458fb452371f4c584.gcfzOx0i14MOBQ7nvtxNXdOhyrG3zuxGFX1MY8SnYCY
insights-insightstable--default--dark:
hash: v1.k794b7964.585aa3b95a71f83db72c958f68b5b9b28c05047625904238a18d840fd4abe38b.kbYrG-uIZ1A_25STyJcDiz6Ph7-N7rkj2HWE6g6eoy8
insights-insightstable--default--light:
diff --git a/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.stories.tsx b/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.stories.tsx
index b7f9c47da517..3782faf04471 100644
--- a/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.stories.tsx
+++ b/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.stories.tsx
@@ -162,6 +162,13 @@ export const ComparePrevious: Story = {
},
}
+// The "Detailed results" table below a chart (not the main insight view): current and previous
+// periods appear as separate rows, so each row needs its compare tag — including with a breakdown.
+export const ComparePreviousDetailedResults: Story = {
+ render: renderCompareInsightsTable,
+ args: {},
+}
+
// A HogQL breakdown expression that is far too long to fit in a column. The header should be clipped
// with an ellipsis rather than overflowing into neighbouring columns.
const LONG_SQL_BREAKDOWN =
diff --git a/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.tsx b/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.tsx
index 2c92087fae84..87b263f642f2 100644
--- a/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.tsx
+++ b/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.tsx
@@ -30,7 +30,7 @@ import {
import { BreakdownColumnItem, BreakdownColumnTitle, MultipleBreakdownColumnTitle } from './columns/BreakdownColumn'
import { ColorCustomizationColumnItem, ColorCustomizationColumnTitle } from './columns/ColorCustomizationColumn'
import { SeriesCheckColumnItem, SeriesCheckColumnTitle } from './columns/SeriesCheckColumn'
-import { SeriesColumnItem } from './columns/SeriesColumn'
+import { SeriesColumnItem, formatCompareLabel } from './columns/SeriesColumn'
import { ValueColumnItem, ValueColumnTitle } from './columns/ValueColumn'
import { WorldMapColumnItem, WorldMapColumnTitle } from './columns/WorldMapColumn'
import { AggregationType, insightsTableDataLogic } from './insightsTableDataLogic'
@@ -185,6 +185,10 @@ export function InsightsTable({
item={item}
formatItemBreakdownLabel={formatItemBreakdownLabel!}
breakdownFilter={breakdownFilter}
+ compareValue={
+ // Formula results synthesized from filler rows can carry compare_label without compare
+ (item.compare || item.compare_label) && !isCompareTable ? formatCompareLabel(item) : undefined
+ }
/>
) : (
<SeriesColumnItem
diff --git a/frontend/src/scenes/insights/views/InsightsTable/columns/BreakdownColumn.tsx b/frontend/src/scenes/insights/views/InsightsTable/columns/BreakdownColumn.tsx
index 38d992b4b6e4..e03545e6cadf 100644
--- a/frontend/src/scenes/insights/views/InsightsTable/columns/BreakdownColumn.tsx
+++ b/frontend/src/scenes/insights/views/InsightsTable/columns/BreakdownColumn.tsx
@@ -1,5 +1,5 @@
import { IconPin, IconPinFilled } from '@posthog/icons'
-import { Link, Tooltip } from '@posthog/lemon-ui'
+import { LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
import { parseAliasToReadable } from 'lib/components/PathCleanFilters/PathCleanFilterItem'
import { PropertyKeyInfo } from 'lib/components/PropertyKeyInfo'
@@ -81,12 +81,15 @@ type BreakdownColumnItemProps = {
item: IndexedTrendResult
formatItemBreakdownLabel: (item: IndexedTrendResult) => string
breakdownFilter?: BreakdownFilter
+ /** "Current"/"Previous" tag, shown when the breakdown label doubles as the series column. */
+ compareValue?: string
}
export function BreakdownColumnItem({
item,
formatItemBreakdownLabel,
breakdownFilter,
+ compareValue,
}: BreakdownColumnItemProps): JSX.Element {
const breakdownLabel = formatItemBreakdownLabel(item)
const showPathCleaningHighlight = breakdownFilter?.breakdown_path_cleaning && typeof breakdownLabel === 'string'
@@ -96,7 +99,7 @@ export function BreakdownColumnItem({
// Clipped with CSS only, so the full value stays in the DOM — copying the cell copies everything
return (
- <div className="flex justify-between items-center">
+ <div className="flex items-center gap-2">
{breakdownLabel && (
<>
{isURL(breakdownLabel) ? (
@@ -116,6 +119,7 @@ export function BreakdownColumnItem({
)}
</>
)}
+ {compareValue && <LemonTag className="tag-pill shrink-0">{compareValue}</LemonTag>}
</div>
)
}
diff --git a/frontend/src/scenes/insights/views/InsightsTable/columns/SeriesColumn.tsx b/frontend/src/scenes/insights/views/InsightsTable/columns/SeriesColumn.tsx
index 501ff3f8300d..bf543f8da0bd 100644
--- a/frontend/src/scenes/insights/views/InsightsTable/columns/SeriesColumn.tsx
+++ b/frontend/src/scenes/insights/views/InsightsTable/columns/SeriesColumn.tsx
@@ -46,7 +46,10 @@ export function SeriesColumnItem({
'font-medium': !hasBreakdown,
})}
pillMaxWidth={165}
- compareValue={item.compare && !hideCompare ? formatCompareLabel(item) : undefined}
+ compareValue={
+ // Formula results synthesized from filler rows can carry compare_label without compare
+ (item.compare || item.compare_label) && !hideCompare ? formatCompareLabel(item) : undefined
+ }
onLabelClick={canEditSeriesNameInline ? () => handleEditClick(item) : undefined}
/>
</div>