: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(funnels): show median time to convert in funnel header (#64389)
Thomas Obermüller8bddd63e8831
diff --git a/ee/clickhouse/views/test/funnel/__snapshots__/test_clickhouse_funnel_unordered.ambr b/ee/clickhouse/views/test/funnel/__snapshots__/test_clickhouse_funnel_unordered.ambrindex 13212fb83c6c..52325f21fa1d 100644--- a/ee/clickhouse/views/test/funnel/__snapshots__/test_clickhouse_funnel_unordered.ambr+++ b/ee/clickhouse/views/test/funnel/__snapshots__/test_clickhouse_funnel_unordered.ambr@@ -6,12 +6,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROMdiff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex c5536da6984c..a4b7383059e1 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -2509,9 +2509,9 @@ snapshots:insights-funnelstepsbarchart--default--light:hash: v1.k794b7964.fe6293e80ff3014aac37a652107195613baf23e61d8612e7a2156478bce8a138.FLFOJroOGoBFApFzYil15PPT2jNF01yQtezK_StFjHUinsights-funneltimetoconverttable--default--dark:- hash: v1.k794b7964.e2a3f17ff6af3123e411605b157f30c5c23d44a2e235e9404d00f3ff58fb622b.hb8Eho7lF-lq_Uy1bzTivTu7Zz1w5F5GfswF_bpsPV4+ hash: v1.k794b7964.705be97725fbf4864c1ee89bfe71f783b8258340a17c845c6c4c7a2ca2649a86.EErdKEVTegibMohKXzFfjUSUW495svDW88KdGAc9eDginsights-funneltimetoconverttable--default--light:- hash: v1.k794b7964.ca567ad1628cef0af8b20165f60bfd42c995fad41a54e065ba4bcc27e2cc9980.0r6gnow2LWF9p8gkZ_05U1VLbGFE2S95wR1GWhOiFpQ+ hash: v1.k794b7964.83cd092fa665620f25c17d1428c1e580b85ce58b656cc2822c0740acc6737672.4d-H48foMqcCvgBqXDofSUrHeYQkq2u2UMQhbtUboU4insights-funneltrendstable--compare--dark:hash: v1.k794b7964.fdf271136de0fb4ac28d7e9020ffb7c26de456a66dbd04fd7c2d8dd6cd7010c6.jSj67TCdgW9Bid3EfaiMeaNI9yvhoPgBOWvAEDsXoi0insights-funneltrendstable--compare--light:@@ -4869,9 +4869,9 @@ snapshots:scenes-app-customer-analytics-dashboard--gated-without-matching-early-access-feature--light:hash: v1.k794b7964.7d6ccd02ee0082c022a3b4df37a08e9ac8607bf47a4fbfa05524fa595a3ab282.mUbv6RihkGQwA0APhk0qNUlX44XfRDv1f1xlV3UuWaQscenes-app-customer-analytics-journey-builder--new-journey--dark:- hash: v1.k794b7964.8d4f5e8abd93455fc41c5c472bbe8424a8a1119c688c3a33869d719baf5f234a.AAJzhdx82JDaI_ANDaMOQsqbeP6kvtm0cLr32iLyACc+ hash: v1.k794b7964.8c09922c7502e589b60efc14da2a6397210ea44c8569d0a1f0b979b67ad4b6e3.a5pXqCNy73E_xKLTywDwvAGpqAW05QJvr-t6Ah1VtWUscenes-app-customer-analytics-journey-builder--new-journey--light:- hash: v1.k794b7964.33eaf28eabade5f850f804a8b825e58cd040f6e463c768a0e864e3386dc6f003.7Ti493BTSwmzCBbO4r1E_QqQm0pN6nZHNDkmCMHz43s+ hash: v1.k794b7964.4ec23fa920fb3a691d7750b60c48f783ba26e7c624b748925f6441730c34104e.CsKc8sb1uPswmMJCu-7XXDPfwET8-oCEF2RgW4EDR4Uscenes-app-customer-analytics-journey-templates--templates-with-events-configured--dark:hash: v1.k794b7964.5e52bdead0cfcfe4f65bffd07da179ec92e7165506f8ed25d7224d86b4e2d18f.L1qeFrgQKgvTXUxv3B3CN-aLKkAF_dk3PmJ8L1u2euoscenes-app-customer-analytics-journey-templates--templates-with-events-configured--light:@@ -4885,17 +4885,17 @@ snapshots:scenes-app-customer-analytics-journeys--empty-state--light:hash: v1.k794b7964.52a1d577d8b3e8ee237b38780bac9afcb9bbf26b2e1c5ba97b5baaa09fcecc93.CeHoa1ffwpMQ-A07wBv5sUuLj-BQoW3pFHjK_qqmz7oscenes-app-customer-analytics-journeys--journey-with-empty-steps--dark:- hash: v1.k794b7964.575197439dab0753c4d91d5080225ebb34e9bfb3939e2c343985190b5d7fc546.jKekiYQiV8z6ymL606jMLq_Vu5YtL6oKf3sbXEBs3Mo+ hash: v1.k794b7964.96014c53c81aa3bfbed304d5f59d5a75022e34e5c4f4c7e461f1af495d163cfd.jzNLk4GIPq8kewh4lbsNY6SXmwziHfcrSu7hijg9HWcscenes-app-customer-analytics-journeys--journey-with-empty-steps--light:- hash: v1.k794b7964.568cf08ab72b05d9bbb46105df72376c0cad5524416da6e50c20dff86d29913c.wSHfsCwRd_W-_68hqzl9WjPQOS2WAtlwH5yp8Weg3to+ hash: v1.k794b7964.f33f0dd149c91921557622973dd8720f653ac8fcc0b2b1f0955561946d138325.D_KAYVY5wjVAnM0Xji-KoY_h8BsWl3cGSNdegAxkFYoscenes-app-customer-analytics-journeys--journey-with-optional-steps--dark:- hash: v1.k794b7964.7b6776c2f8b58b1ddffe71b174103e7e9dd0127d377c094aff1ecb347496cdac.E0EhWVCIoAPgsbg7Y9UOj94hRWgs46kKoRYW-6n7o8E+ hash: v1.k794b7964.6440e0dd4cafc8c405739907aa8f686be4dd751f3476c01f8dbe8a4c4c05155c.bsUTuVoP0ATrpGah2OIP61JZcGuJB42ZVHDW1ka0K_Qscenes-app-customer-analytics-journeys--journey-with-optional-steps--light:hash: v1.k794b7964.e7bc20e1000e085dd8ff1df197237996c89ca41a49bc85a9196d7810cdbb99b3.TJAkAus1O-nLpH0DbgV3I3iNIyCmy-pkRAB9mXOH9swscenes-app-customer-analytics-journeys--journey-with-required-steps--dark:- hash: v1.k794b7964.f191a2a8d8cee4fce45f5c087a4ba9178a53541dc5bffe66e262e4b1a69422b1.NxV1O1i_oGKplaKZTzJ1MTHLYr64hscedmzn1Q4zMGU+ hash: v1.k794b7964.07a86fda5dc270067bf5d0dba3149b2a4fadb19164d33e28d4ab8a23fe93b871.bNyN1SNVwq3gND-vrn-DAesggTaEhggm3sPS1TiiggIscenes-app-customer-analytics-journeys--journey-with-required-steps--light:- hash: v1.k794b7964.4b19483ac2bdaecad600badecceaff11b03741d0fe8adea25f6e6ae0755411b0.x8M01k87Kw-7cOj9L-sM1CQHd3BDspSlYdoCaMvJIB0+ hash: v1.k794b7964.b6d8cddafb01447a2e9ee5bb1e01a927ace110f995040f2603449205ed8a39ce.obRlWW7dWF7-goXBNCaBiaDyRxoUKN55V7Itk_jGVoMscenes-app-customer-analytics-journeys-nodes-builderpathflownode--all-variants--dark:hash: v1.k794b7964.8a9c965ccc0120f1cc67cb102fec65f0430c6f82b8093be93bb343c2dec4ca8c.ZVj7XydD6QOuxYLe5XNliqupVSH2WwEVl__cx2nM7kQscenes-app-customer-analytics-journeys-nodes-builderpathflownode--all-variants--light:diff --git a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRight.json b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRight.jsonindex 10aac1d204d8..59b1de9add5d 100644--- a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRight.json+++ b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRight.json@@ -12,6 +12,7 @@"color": null,"last_refresh": null,"refreshing": false,+ "total_median_conversion_time": 691.5,"result": [{"action_id": "$pageview",diff --git a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightBreakdown.json b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightBreakdown.jsonindex 8479c5632c83..60059da7cac9 100644--- a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightBreakdown.json+++ b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightBreakdown.json@@ -12,6 +12,7 @@"color": null,"last_refresh": null,"refreshing": false,+ "total_median_conversion_time": 691.5,"result": [[{diff --git a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightCompare.json b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightCompare.jsonindex d1649635ad60..ecb8194e0553 100644--- a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightCompare.json+++ b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightCompare.json@@ -12,6 +12,7 @@"color": null,"last_refresh": null,"refreshing": false,+ "total_median_conversion_time": 691.5,"result": [{"action_id": "$pageview",diff --git a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightWithInlineEvents.json b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightWithInlineEvents.jsonindex dfe26494b89c..2496c2912076 100644--- a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightWithInlineEvents.json+++ b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelLeftToRightWithInlineEvents.json@@ -12,6 +12,7 @@"color": null,"last_refresh": null,"refreshing": false,+ "total_median_conversion_time": 691.5,"result": [{"action_id": "$pageview, $pageleave",diff --git a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTimeToConvert.json b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTimeToConvert.jsonindex 8a1571dda575..ba8388f9cd10 100644--- a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTimeToConvert.json+++ b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTimeToConvert.json@@ -33,6 +33,7 @@[230960, 1],[245395, 0]],+ "median_conversion_time": 691.5,"average_conversion_time": 1060.7},"created_at": "2022-03-15T21:31:00.192917Z",diff --git a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTimeToConvertCompare.json b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTimeToConvertCompare.jsonindex 567928dd98e5..8fdf9df83610 100644--- a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTimeToConvertCompare.json+++ b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTimeToConvertCompare.json@@ -41,6 +41,7 @@[101045, 1],[115480, 3]],+ "median_conversion_time": 691.5,"average_conversion_time": 1340.2}],diff --git a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottom.json b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottom.jsonindex 029df9078b65..0d060f870b8e 100644--- a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottom.json+++ b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottom.json@@ -12,6 +12,7 @@"color": null,"last_refresh": null,"refreshing": false,+ "total_median_conversion_time": 691.5,"result": [{"action_id": "$pageview",diff --git a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomBreakdown.json b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomBreakdown.jsonindex 7b5bada1655d..888da819ad92 100644--- a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomBreakdown.json+++ b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomBreakdown.json@@ -12,6 +12,7 @@"color": null,"last_refresh": null,"refreshing": false,+ "total_median_conversion_time": 691.5,"result": [[{diff --git a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomBreakdownCompare.json b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomBreakdownCompare.jsonindex 8cd7b1738ed3..0a991545e89a 100644--- a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomBreakdownCompare.json+++ b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomBreakdownCompare.json@@ -12,6 +12,7 @@"color": null,"last_refresh": null,"refreshing": false,+ "total_median_conversion_time": 691.5,"result": [[{diff --git a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomCompare.json b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomCompare.jsonindex 029274ec4518..34a5e9c361c3 100644--- a/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomCompare.json+++ b/frontend/src/mocks/fixtures/api/projects/team_id/insights/funnelTopToBottomCompare.json@@ -16,6 +16,7 @@"date_from": "2022-03-08T00:00:00Z","date_to": "2022-03-15T23:59:59Z"},+ "total_median_conversion_time": 691.5,"result": [{"action_id": "$pageview",diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 5cebf64dd7bc..f78b263bb541 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -7073,6 +7073,10 @@},"type": "array"},+ "total_median_conversion_time": {+ "description": "Median total conversion time across all completers, computed breakdown-agnostically for the Steps viz header.",+ "type": ["number", "null"]+ },"warnings": {"description": "Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries.","items": {@@ -22423,9 +22427,12 @@"type": "array"},"type": "array"+ },+ "median_conversion_time": {+ "type": ["number", "null"]}},- "required": ["average_conversion_time", "bins"],+ "required": ["average_conversion_time", "median_conversion_time", "bins"],"type": "object"},"FunnelTrendsResults": {@@ -22909,6 +22916,10 @@},"type": "array"},+ "total_median_conversion_time": {+ "description": "Median total conversion time across all completers, computed breakdown-agnostically for the Steps viz header.",+ "type": ["number", "null"]+ },"warnings": {"description": "Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries.","items": {@@ -35637,6 +35648,10 @@},"type": "array"},+ "total_median_conversion_time": {+ "description": "Median total conversion time across all completers, computed breakdown-agnostically for the Steps viz header.",+ "type": ["number", "null"]+ },"warnings": {"description": "Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries.","items": {diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex c5796ebed419..6d4897d411bc 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -1772,6 +1772,7 @@ export type FunnelStepsResults = Record<string, any>[]export type FunnelStepsBreakdownResults = Record<string, any>[][]export type FunnelTimeToConvertResults = {average_conversion_time: number | null+ median_conversion_time: number | nullbins: [BinNumber, BinNumber][]}export type FunnelTrendsResults = Record<string, any>[]@@ -1779,6 +1780,8 @@ export interface FunnelsQueryResponse extends AnalyticsQueryResponseBase {// This is properly FunnelStepsResults | FunnelStepsBreakdownResults | FunnelTimeToConvertResults | FunnelTrendsResults// but this large of a union doesn't provide any type-safety and causes python mypy issues, so represented as any.results: any+ /** Median total conversion time across all completers, computed breakdown-agnostically for the Steps viz header. */+ total_median_conversion_time?: number | null}export type CachedFunnelsQueryResponse = CachedQueryResponse<FunnelsQueryResponse>diff --git a/frontend/src/scenes/funnels/FunnelCanvasLabel.tsx b/frontend/src/scenes/funnels/FunnelCanvasLabel.tsxindex 67531fd832b7..a2a1f4d1a010 100644--- a/frontend/src/scenes/funnels/FunnelCanvasLabel.tsx+++ b/frontend/src/scenes/funnels/FunnelCanvasLabel.tsx@@ -39,27 +39,27 @@ export function FunnelCanvasLabel(): JSX.Element | null {</>,]: []),- ...(funnelsFilter?.funnelVizType !== FunnelVizType.Trends+ ...(funnelsFilter?.funnelVizType !== FunnelVizType.Trends && conversionMetrics.medianTime != null? [<><span className="flex items-center text-secondary"><Tooltip- title={`Average (arithmetic mean) of the total time each ${aggregationTargetLabel.singular} spent in the entire funnel.`}+ title={`Median (50th percentile) of the total time each ${aggregationTargetLabel.singular} spent in the entire funnel.`}><IconInfo className="mr-1 text-xl shrink-0" /></Tooltip>- <span>Average time to convert</span>+ <span>Median time to convert</span></span>{funnelsFilter?.funnelVizType === FunnelVizType.TimeToConvert && <FunnelStepsPicker />}<span className="text-secondary mr-1">:</span>{funnelsFilter?.funnelVizType === FunnelVizType.TimeToConvert ? (- <span className="font-bold">{humanFriendlyDuration(conversionMetrics.averageTime)}</span>+ <span className="font-bold">{humanFriendlyDuration(conversionMetrics.medianTime)}</span>) : (<LinkclassName="font-bold"onClick={() => updateInsightFilter({ funnelVizType: FunnelVizType.TimeToConvert })}>- {humanFriendlyDuration(conversionMetrics.averageTime)}+ {humanFriendlyDuration(conversionMetrics.medianTime)}</Link>)}</>,diff --git a/frontend/src/scenes/funnels/FunnelFlowGraph/FunnelFlowGraph.stories.tsx b/frontend/src/scenes/funnels/FunnelFlowGraph/FunnelFlowGraph.stories.tsxindex 5967bf380493..b8dbd7df36e5 100644--- a/frontend/src/scenes/funnels/FunnelFlowGraph/FunnelFlowGraph.stories.tsx+++ b/frontend/src/scenes/funnels/FunnelFlowGraph/FunnelFlowGraph.stories.tsx@@ -40,7 +40,12 @@ export const JourneyWithRequiredSteps: Story = {render: () => {useStorybookMocks({get: { 'api/environments/:team_id/insights/1/': makeInsight() },- post: { 'api/environments/:team_id/query/FunnelsQuery/': { result: allCompletedSteps() } },+ post: {+ 'api/environments/:team_id/query/FunnelsQuery/': {+ result: allCompletedSteps(),+ total_median_conversion_time: 270,+ },+ },})return <App />},@@ -54,7 +59,12 @@ export const JourneyWithEmptySteps: Story = {render: () => {useStorybookMocks({get: { 'api/environments/:team_id/insights/1/': makeInsight() },- post: { 'api/environments/:team_id/query/FunnelsQuery/': { result: someCompletedSteps() } },+ post: {+ 'api/environments/:team_id/query/FunnelsQuery/': {+ result: someCompletedSteps(),+ total_median_conversion_time: 90,+ },+ },})return <App />},@@ -68,7 +78,12 @@ export const JourneyWithOptionalSteps: Story = {render: () => {useStorybookMocks({get: { 'api/environments/:team_id/insights/1/': makeInsight([1, 3]) },- post: { 'api/environments/:team_id/query/FunnelsQuery/': { result: optionalStepResults() } },+ post: {+ 'api/environments/:team_id/query/FunnelsQuery/': {+ result: optionalStepResults(),+ total_median_conversion_time: 180,+ },+ },})return <App />},diff --git a/frontend/src/scenes/funnels/__mocks__/funnelDataLogicMocks.ts b/frontend/src/scenes/funnels/__mocks__/funnelDataLogicMocks.tsindex 3112799c5d5b..1c600f641072 100644--- a/frontend/src/scenes/funnels/__mocks__/funnelDataLogicMocks.ts+++ b/frontend/src/scenes/funnels/__mocks__/funnelDataLogicMocks.ts@@ -283,6 +283,7 @@ export const funnelResultTimeToConvert: FunnelAPIResponse = {[441526.0, 0],],average_conversion_time: 86456.76,+ median_conversion_time: 60492.5,},timezone: 'UTC',last_refresh: '2023-02-22T17:32:24.245364Z',@@ -299,6 +300,7 @@ export const funnelResultTimeToConvertWithoutConversions: FunnelAPIResponse = {[1.0, 0],],average_conversion_time: null,+ median_conversion_time: null,},timezone: 'UTC',last_refresh: '2023-03-03T12:02:22.618420Z',@@ -319,6 +321,7 @@ export const funnelResultTimeToConvertCompare: FunnelAPIResponse = {[147178.0, 10],],average_conversion_time: 86456.76,+ median_conversion_time: 60492.5,},{compare_label: 'previous',@@ -328,6 +331,7 @@ export const funnelResultTimeToConvertCompare: FunnelAPIResponse = {[147178.0, 17],],average_conversion_time: 91230.5,+ median_conversion_time: 65000.0,},] as any,timezone: 'UTC',diff --git a/frontend/src/scenes/funnels/funnelDataLogic.test.ts b/frontend/src/scenes/funnels/funnelDataLogic.test.tsindex 1f3dc06394cb..45c5a740c1c7 100644--- a/frontend/src/scenes/funnels/funnelDataLogic.test.ts+++ b/frontend/src/scenes/funnels/funnelDataLogic.test.ts@@ -1095,14 +1095,16 @@ describe('funnelDataLogic', () => {insight: InsightType.FUNNELS,},result: funnelResult.result,- }+ // Funnel-level median is carried as a top-level field on the response, not summed from steps.+ total_median_conversion_time: 208.75,+ } as anyawait expectLogic(logic, () => {builtDataNodeLogic.actions.loadDataSuccess(insight)logic.actions.updateQuerySource(query)}).toMatchValues({conversionMetrics: {- averageTime: 87098.67529697785,+ medianTime: 208.75,stepRate: 0.46048109965635736,totalRate: 0.46048109965635736,},@@ -1129,7 +1131,7 @@ describe('funnelDataLogic', () => {builtDataNodeLogic.actions.loadDataSuccess(insight)}).toMatchValues({conversionMetrics: {- averageTime: 86456.76, // from backend+ medianTime: 60492.5, // from backendstepRate: 0,totalRate: 0,},@@ -1157,12 +1159,71 @@ describe('funnelDataLogic', () => {logic.actions.updateQuerySource(query)}).toMatchValues({conversionMetrics: {- averageTime: 0,+ medianTime: null,stepRate: 0,totalRate: 0.7120000000000001, // avg(steps[0] / 100)},})})++ it('for steps viz when median is missing (old cache)', async () => {+ const query: FunnelsQuery = {+ kind: NodeKind.FunnelsQuery,+ series: [],+ funnelsFilter: {+ funnelVizType: FunnelVizType.Steps,+ },+ }++ // No total_median_conversion_time — mirrors a result cached before the field existed.+ const insight: Partial<InsightModel> = {+ filters: {+ insight: InsightType.FUNNELS,+ },+ result: funnelResult.result,+ }++ await expectLogic(logic, () => {+ builtDataNodeLogic.actions.loadDataSuccess(insight)+ logic.actions.updateQuerySource(query)+ }).toMatchValues({+ conversionMetrics: {+ medianTime: null,+ stepRate: 0.46048109965635736,+ totalRate: 0.46048109965635736,+ },+ })+ })++ it('for time to convert viz when median is missing (old cache)', async () => {+ const query: FunnelsQuery = {+ kind: NodeKind.FunnelsQuery,+ series: [],+ funnelsFilter: {+ funnelVizType: FunnelVizType.TimeToConvert,+ },+ }+ const insight: Partial<InsightModel> = {+ filters: {+ insight: InsightType.FUNNELS,+ },+ result: {+ bins: (funnelResultTimeToConvert.result as any).bins,+ average_conversion_time: (funnelResultTimeToConvert.result as any).average_conversion_time,+ },+ } as any++ await expectLogic(logic, () => {+ logic.actions.updateQuerySource(query)+ builtDataNodeLogic.actions.loadDataSuccess(insight)+ }).toMatchValues({+ conversionMetrics: {+ medianTime: null,+ stepRate: 0,+ totalRate: 0,+ },+ })+ })})describe('conversionWindow', () => {diff --git a/frontend/src/scenes/funnels/funnelDataLogic.ts b/frontend/src/scenes/funnels/funnelDataLogic.tsindex ae6294d3ec69..5b9ee20eee6e 100644--- a/frontend/src/scenes/funnels/funnelDataLogic.ts+++ b/frontend/src/scenes/funnels/funnelDataLogic.ts@@ -17,7 +17,7 @@ import { getFunnelDatasetKey, getFunnelResultCustomizationColorToken } from 'sceimport { Noun, groupsModel } from '~/models/groupsModel'import { seriesNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'import { FunnelExclusionSteps, InsightQueryNode } from '~/queries/schema/schema-general'-import { FunnelsFilter, FunnelsQuery, NodeKind } from '~/queries/schema/schema-general'+import { FunnelsFilter, FunnelsQuery, FunnelsQueryResponse, NodeKind } from '~/queries/schema/schema-general'import { isFunnelsQuery, isWebOverviewQuery, isWebStatsTableQuery } from '~/queries/utils'import {FlattenedFunnelStepByBreakdown,@@ -651,12 +651,12 @@ export const funnelDataLogic = kea<funnelDataLogicType>([],conversionMetrics: [- (s) => [s.steps, s.funnelsFilter, s.timeConversionResults],- (steps, funnelsFilter, timeConversionResults): FunnelTimeConversionMetrics => {+ (s) => [s.steps, s.funnelsFilter, s.timeConversionResults, s.insightData],+ (steps, funnelsFilter, timeConversionResults, insightData): FunnelTimeConversionMetrics => {// steps should be empty in time conversion view. Return metrics precalculated on backendif (funnelsFilter?.funnelVizType === FunnelVizType.TimeToConvert) {return {- averageTime: timeConversionResults?.average_conversion_time ?? 0,+ medianTime: timeConversionResults?.median_conversion_time ?? null,stepRate: 0,totalRate: 0,}@@ -665,7 +665,7 @@ export const funnelDataLogic = kea<funnelDataLogicType>([// Handle metrics for trendsif (funnelsFilter?.funnelVizType === FunnelVizType.Trends) {return {- averageTime: 0,+ medianTime: null,stepRate: 0,totalRate: average((steps?.[0] as unknown as TrendResult)?.data ?? []) / 100,}@@ -675,7 +675,7 @@ export const funnelDataLogic = kea<funnelDataLogicType>([// no concept of funnel_from_step and funnel_to_step hereif (steps.length <= 1) {return {- averageTime: 0,+ medianTime: null,stepRate: 0,totalRate: 0,}@@ -685,10 +685,9 @@ export const funnelDataLogic = kea<funnelDataLogicType>([const fromStep = getReferenceStep(steps, FunnelStepReference.total)return {- averageTime: steps.reduce(- (conversion_time, step) => conversion_time + (step.average_conversion_time || 0),- 0- ),+ // The median of the total funnel time isn't the sum of per-step medians, so it's+ // computed breakdown-agnostically on the backend and carried as a top-level field.+ medianTime: (insightData as Partial<FunnelsQueryResponse>).total_median_conversion_time ?? null,stepRate: fromStep.count === 0 ? 0 : toStep.count / fromStep.count,totalRate: steps[0].count === 0 ? 0 : steps[steps.length - 1].count / steps[0].count,}diff --git a/frontend/src/scenes/insights/__mocks__/createInsightScene.tsx b/frontend/src/scenes/insights/__mocks__/createInsightScene.tsxindex 8bfa97d9a9e5..16e1673a75ad 100644--- a/frontend/src/scenes/insights/__mocks__/createInsightScene.tsx+++ b/frontend/src/scenes/insights/__mocks__/createInsightScene.tsx@@ -86,6 +86,8 @@ export function createInsightStory(// sql insightscolumns: (insight as any).columns,types: (insight as any).types,+ // funnel steps header reads the total median from this top-level field+ total_median_conversion_time: (insight as any).total_median_conversion_time,},],},diff --git a/frontend/src/scenes/insights/views/Funnels/FunnelTimeToConvertTable.tsx b/frontend/src/scenes/insights/views/Funnels/FunnelTimeToConvertTable.tsxindex 4128ecd3ac3f..c4ccd024754b 100644--- a/frontend/src/scenes/insights/views/Funnels/FunnelTimeToConvertTable.tsx+++ b/frontend/src/scenes/insights/views/Funnels/FunnelTimeToConvertTable.tsx@@ -65,7 +65,7 @@ export function FunnelTimeToConvertTable(): JSX.Element | null {]: [timeRangeColumn, conversionsColumn, percentColumn]- const previousAverageTime = timeConversionResultsPrevious?.average_conversion_time+ const previousMedianTime = timeConversionResultsPrevious?.median_conversion_timereturn (<LemonTable@@ -75,17 +75,17 @@ export function FunnelTimeToConvertTable(): JSX.Element | null {rowKey="id"data-attr="funnel-time-to-convert-table"footer={- conversionMetrics.averageTime ? (+ conversionMetrics.medianTime ? (<div className="flex items-center justify-between px-2 py-1">- <span className="font-medium">Average time to convert</span>+ <span className="font-medium">Median time to convert</span><span>- {humanFriendlyDuration(conversionMetrics.averageTime, { maxUnits: 3 })}+ {humanFriendlyDuration(conversionMetrics.medianTime, { maxUnits: 3 })}{isComparing && (<span className="text-secondary">{' '}(current) ·{' '}- {previousAverageTime- ? `${humanFriendlyDuration(previousAverageTime, { maxUnits: 3 })} (previous)`+ {previousMedianTime+ ? `${humanFriendlyDuration(previousMedianTime, { maxUnits: 3 })} (previous)`: '– (previous)'}</span>)}diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 2880cbf2efee..c398c0b67eab 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -3385,6 +3385,7 @@ export interface FunnelStep {export interface FunnelsTimeConversionBins {bins: [number, number][]average_conversion_time: number | null+ median_conversion_time: number | null}export type FunnelResultType = FunnelStep[] | FunnelStep[][] | FunnelsTimeConversionBins@@ -3401,7 +3402,8 @@ export interface FunnelStepWithNestedBreakdown extends FunnelStep {}export interface FunnelTimeConversionMetrics {- averageTime: number+ /** Null when the result predates the median field (old cache) — the header hides the figure in that case. */+ medianTime: number | nullstepRate: numbertotalRate: number}diff --git a/posthog/hogql/functions/config.py b/posthog/hogql/functions/config.pyindex c6d0929c0a7d..a1f0db1fc0fa 100644--- a/posthog/hogql/functions/config.py+++ b/posthog/hogql/functions/config.py@@ -16,6 +16,7 @@ HOGQL_PERMITTED_PARAMETRIC_FUNCTIONS: set[str] = {"avgState","avgMap","avgMapState",+ "median","uniq","uniqState","uniqMap",diff --git a/posthog/hogql_queries/insights/funnels/base.py b/posthog/hogql_queries/insights/funnels/base.pyindex dc3492e68640..c6cd7a765678 100644--- a/posthog/hogql_queries/insights/funnels/base.py+++ b/posthog/hogql_queries/insights/funnels/base.py@@ -95,6 +95,10 @@ class FunnelBase(ABC):return Falsereturn len(self.breakdown_cohorts) == 1+ def _extract_total_median_conversion_time(self, results, columns) -> Optional[float]:+ """Funnel-level median of total conversion time. Only the Steps viz computes one; others return None."""+ return None+def _format_results(self, results) -> Union[FunnelTimeToConvertResults, list[dict[str, Any]], list[list[dict[str, Any]]]]:diff --git a/posthog/hogql_queries/insights/funnels/funnel.py b/posthog/hogql_queries/insights/funnels/funnel.pyindex b99e780f7c29..f9027e74cc29 100644--- a/posthog/hogql_queries/insights/funnels/funnel.py+++ b/posthog/hogql_queries/insights/funnels/funnel.py@@ -244,11 +244,19 @@ class FunnelUDF(FunnelUDFMixin, FunnelBase):)order_by = ",".join([f"step_{i + 1} DESC" for i in reversed(range(self.context.max_steps))])+ # Per-breakdown array of the total time each completer spent in the entire funnel. The global+ # median is computed once in the outer query (bounded by the breakdown limit) rather than here,+ # where the number of breakdown groups is unbounded.+ total_conversion_times = (+ f"groupArrayIf(arraySum(timings), step_reached >= {self.context.max_steps - 1}) AS total_conversion_times"+ )+s = parse_select(f"""SELECT{step_results},{conversion_time_arrays},+ {total_conversion_times},rowNumberInAllBlocks() as row_number,{final_prop} as final_propFROM@@ -267,6 +275,7 @@ class FunnelUDF(FunnelUDFMixin, FunnelBase):ast.Alias(alias=f"step_{i}_conversion_times", expr=ast.Array(exprs=[]))for i in range(1, self.context.max_steps))+ columns.append(ast.Alias(alias="total_conversion_times", expr=ast.Array(exprs=[])))columns.append(ast.Alias(alias="row_number", expr=ast.Constant(value=0)))columns.append(ast.Alias(alias="final_prop", expr=ast.Constant(value=NOT_IN_COHORT_ID)))synthetic_row = ast.SelectQuery(select=columns)@@ -285,6 +294,16 @@ class FunnelUDF(FunnelUDFMixin, FunnelBase):])+ # Global median of every completer's total funnel time, breakdown-agnostic (a single header number).+ # Computed here, where rows are bounded by the breakdown limit: each final_prop group flattens its+ # completer times, the window over () spans all groups, and arrayReduce keeps it a scalar (medianArray+ # is an aggregate and can't wrap the windowed aggregate). An empty array yields NaN, coerced to NULL.+ total_median_conversion_time = (+ "arrayMap(x -> if(isNaN(x), NULL, x), "+ "[arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] "+ "AS total_median_conversion_time"+ )+order_by = ",".join([f"step_{i + 1} DESC" for i in reversed(range(self.context.max_steps))])# Weird: unless you reference row_number in this outer block, it doesn't work correctlys = cast(@@ -295,6 +314,7 @@ class FunnelUDF(FunnelUDFMixin, FunnelBase):{step_results2},{mean_conversion_times},{median_conversion_times},+ {total_median_conversion_time},groupArray(row_number) as row_number,final_propFROM@@ -433,6 +453,17 @@ class FunnelUDF(FunnelUDFMixin, FunnelBase):settings=HogQLQuerySettings(join_algorithm=JOIN_ALGOS),)+ def _extract_total_median_conversion_time(self, results, columns) -> Optional[float]:+ # Identical across every output row (windowed over all breakdowns); read it off the first row.+ # Looked up by column name so it's robust to changes in the outer SELECT's column order.+ if not results or not columns:+ return None+ try:+ index = columns.index("total_median_conversion_time")+ except ValueError:+ return None+ return results[0][index]+def _format_single_funnel(self, results, with_breakdown=False):max_steps = self.context.max_stepsdiff --git a/posthog/hogql_queries/insights/funnels/funnel_time_to_convert.py b/posthog/hogql_queries/insights/funnels/funnel_time_to_convert.pyindex b0f28cef8bdd..81d95e4f9e89 100644--- a/posthog/hogql_queries/insights/funnels/funnel_time_to_convert.py+++ b/posthog/hogql_queries/insights/funnels/funnel_time_to_convert.py@@ -24,8 +24,9 @@ class FunnelTimeToConvertUDF(FunnelBase):def _format_results(self, results: list) -> FunnelTimeToConvertResults:return FunnelTimeToConvertResults(- bins=[[bin_from_seconds, person_count] for bin_from_seconds, person_count, _ in results],+ bins=[[bin_from_seconds, person_count] for bin_from_seconds, person_count, _, _ in results],average_conversion_time=results[0][2],+ median_conversion_time=results[0][3],)def _from_to_steps(self) -> tuple[int, int]:@@ -126,7 +127,8 @@ class FunnelTimeToConvertUDF(FunnelBase):SELECTbin_from_seconds,person_count,- arrayAvg(timings) as averageConversionTime+ arrayAvg(timings) as averageConversionTime,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', timings)])[1] as medianConversionTimeFROM {bins}ARRAY JOINcounts as person_count,diff --git a/posthog/hogql_queries/insights/funnels/funnels_query_runner.py b/posthog/hogql_queries/insights/funnels/funnels_query_runner.pyindex ea736ba5b510..af5bbbfab7dd 100644--- a/posthog/hogql_queries/insights/funnels/funnels_query_runner.py+++ b/posthog/hogql_queries/insights/funnels/funnels_query_runner.py@@ -163,12 +163,16 @@ class FunnelsQueryRunner(AnalyticsQueryRunner[FunnelsQueryResponse]):)results = funnel_class._format_results(response.results)+ total_median_conversion_time = funnel_class._extract_total_median_conversion_time(+ response.results, response.columns+ )if response.timings is not None:timings.extend(response.timings)return FunnelsQueryResponse(results=results,+ total_median_conversion_time=total_median_conversion_time,timings=timings,hogql=hogql,modifiers=self.modifiers,diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambrindex 7ae10dfb4cba..e3620256fea2 100644--- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambr+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambr@@ -5,12 +5,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -66,12 +68,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -138,6 +142,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -146,6 +151,7 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -285,6 +291,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -293,6 +300,7 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -368,12 +376,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -442,6 +452,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -450,6 +461,7 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -745,12 +757,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -816,12 +830,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -884,12 +900,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -954,12 +972,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -1024,12 +1044,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -1097,6 +1119,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -1105,6 +1128,7 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, 'Other') AS final_propFROM@@ -1176,6 +1200,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ max(total_median_conversion_time) AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -1184,6 +1209,8 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(total_conversion_times) OVER ()))])[1] AS total_median_conversion_time,rowNumberInAllBlocks() AS row_number,if(ifNull(less(row_number, 25), 0), breakdown, 'Other') AS final_propFROM@@ -1254,6 +1281,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -1262,6 +1290,7 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, 'Other') AS final_propFROMdiff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambrindex 23d2b6d46dca..371129111fa8 100644--- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambr+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambr@@ -5,12 +5,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 100), breakdown, ['Other']) AS final_propFROM@@ -75,12 +77,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 100), breakdown, ['Other']) AS final_propFROM@@ -145,12 +149,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 100), breakdown, ['Other']) AS final_propFROM@@ -215,12 +221,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 100), breakdown, ['Other']) AS final_propFROMdiff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_data_warehouse.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_data_warehouse.ambrindex 008a70717d15..8270ac7577f8 100644--- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_data_warehouse.ambr+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_data_warehouse.ambr@@ -5,12 +5,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -67,12 +69,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -153,12 +157,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -317,12 +323,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -379,12 +387,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -441,12 +451,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -506,6 +518,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -514,6 +527,7 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROMdiff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambrindex 0848e4e83540..ac92b0899ee3 100644--- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambr+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambr@@ -5,12 +5,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -75,12 +77,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -145,12 +149,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -218,6 +224,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -226,6 +233,7 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, 'Other') AS final_propFROM@@ -297,6 +305,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ max(total_median_conversion_time) AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -305,6 +314,8 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(total_conversion_times) OVER ()))])[1] AS total_median_conversion_time,rowNumberInAllBlocks() AS row_number,if(ifNull(less(row_number, 25), 0), breakdown, 'Other') AS final_propFROM@@ -375,6 +386,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -383,6 +395,7 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, 'Other') AS final_propFROMdiff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambrindex 8264ba534039..1d9d3688ee8f 100644--- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambr+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambr@@ -3,7 +3,8 @@'''SELECT bin_from_seconds,person_count,- arrayAvg(timings) AS averageConversionTime+ arrayAvg(timings) AS averageConversionTime,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', timings)])[1] AS medianConversionTimeFROM(SELECT timings AS timings,accurateCastOrNull(least(60, greatest(1, ceil(cbrt(ifNull(length(timings), 0))))), 'Int64') AS bin_count,@@ -71,7 +72,8 @@'''SELECT bin_from_seconds,person_count,- arrayAvg(timings) AS averageConversionTime+ arrayAvg(timings) AS averageConversionTime,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', timings)])[1] AS medianConversionTimeFROM(SELECT timings AS timings,accurateCastOrNull(least(60, greatest(1, ceil(cbrt(ifNull(length(timings), 0))))), 'Int64') AS bin_count,@@ -139,7 +141,8 @@'''SELECT bin_from_seconds,person_count,- arrayAvg(timings) AS averageConversionTime+ arrayAvg(timings) AS averageConversionTime,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', timings)])[1] AS medianConversionTimeFROM(SELECT timings AS timings,accurateCastOrNull(least(60, greatest(1, ceil(cbrt(ifNull(length(timings), 0))))), 'Int64') AS bin_count,diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambrindex 10bf83cdcb5d..3ac32925c44d 100644--- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr+++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr@@ -8,6 +8,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -16,6 +17,7 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, 'Other') AS final_propFROM@@ -87,6 +89,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ max(total_median_conversion_time) AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -95,6 +98,8 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(total_conversion_times) OVER ()))])[1] AS total_median_conversion_time,rowNumberInAllBlocks() AS row_number,if(ifNull(less(row_number, 25), 0), breakdown, 'Other') AS final_propFROM@@ -165,6 +170,7 @@arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_2_conversion_times)])[1] AS step_2_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_2_conversion_times)])[1] AS step_2_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM@@ -173,6 +179,7 @@countIf(ifNull(notEquals(bitAnd(steps_bitfield, 4), 0), 1)) AS step_3,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,groupArrayIf(timings[2], ifNull(greater(timings[2], 0), 0)) AS step_2_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 2), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, 'Other') AS final_propFROM@@ -532,12 +539,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -602,12 +611,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROMdiff --git a/posthog/hogql_queries/insights/funnels/test/test_funnel.py b/posthog/hogql_queries/insights/funnels/test/test_funnel.pyindex 5fe9e5fdeba8..9355da9cb1da 100644--- a/posthog/hogql_queries/insights/funnels/test/test_funnel.py+++ b/posthog/hogql_queries/insights/funnels/test/test_funnel.py@@ -4134,6 +4134,69 @@ class TestFOSSFunnelUDF(ClickhouseTestMixin, APIBaseTest):self.assertEqual(results[1]["average_conversion_time"], 1_207_020)self.assertEqual(results[1]["median_conversion_time"], 1_207_020)+ def test_total_median_conversion_time(self):+ _create_person(distinct_ids=["user_fast"], team=self.team)+ _create_person(distinct_ids=["user_mid"], team=self.team)+ _create_person(distinct_ids=["user_slow"], team=self.team)+ _create_person(distinct_ids=["user_dropoff"], team=self.team)++ # Three completers convert in 100s / 200s / 900s; the dropoff never reaches step 2 and is excluded.+ # Browser is set so we can verify the median stays global (breakdown-agnostic) below.+ events_by_person = {+ "user_fast": [+ {+ "event": "$pageview",+ "timestamp": datetime(2024, 3, 1, 12, 0, 0),+ "properties": {"$browser": "Chrome"},+ },+ {"event": "user signed up", "timestamp": datetime(2024, 3, 1, 12, 1, 40)},+ ],+ "user_mid": [+ {+ "event": "$pageview",+ "timestamp": datetime(2024, 3, 1, 12, 0, 0),+ "properties": {"$browser": "Chrome"},+ },+ {"event": "user signed up", "timestamp": datetime(2024, 3, 1, 12, 3, 20)},+ ],+ "user_slow": [+ {+ "event": "$pageview",+ "timestamp": datetime(2024, 3, 1, 12, 0, 0),+ "properties": {"$browser": "Safari"},+ },+ {"event": "user signed up", "timestamp": datetime(2024, 3, 1, 12, 15, 0)},+ ],+ "user_dropoff": [+ {+ "event": "$pageview",+ "timestamp": datetime(2024, 3, 1, 12, 0, 0),+ "properties": {"$browser": "Safari"},+ },+ ],+ }+ journeys_for(events_by_person, self.team)++ series = [+ EventsNode(event="$pageview", name="$pageview"),+ EventsNode(event="user signed up", name="user signed up"),+ ]+ date_range = DateRange(date_from="2024-02-17", date_to="2024-03-18")++ query = FunnelsQuery(dateRange=date_range, series=series)+ response = FunnelsQueryRunner(query=query, team=self.team).calculate()+ # Median of [100, 200, 900] is 200; the dropoff has no full-funnel time and doesn't count.+ self.assertEqual(response.total_median_conversion_time, 200)++ # With a breakdown active the median is still computed over all completers, not per browser.+ breakdown_query = FunnelsQuery(+ dateRange=date_range,+ series=series,+ breakdownFilter=BreakdownFilter(breakdown="$browser", breakdown_type=BreakdownType.EVENT),+ )+ breakdown_response = FunnelsQueryRunner(query=breakdown_query, team=self.team).calculate()+ self.assertEqual(breakdown_response.total_median_conversion_time, 200)+def test_parses_breakdowns_correctly(self):_create_person(distinct_ids=[f"user_1"],diff --git a/posthog/hogql_queries/insights/funnels/test/test_funnel_time_to_convert.py b/posthog/hogql_queries/insights/funnels/test/test_funnel_time_to_convert.pyindex bc32729d884c..9a1bd202c566 100644--- a/posthog/hogql_queries/insights/funnels/test/test_funnel_time_to_convert.py+++ b/posthog/hogql_queries/insights/funnels/test/test_funnel_time_to_convert.py@@ -124,6 +124,7 @@ class TestFunnelTimeToConvert(ClickhouseTestMixin, APIBaseTest):], # Reached step 1 from step 0 in at least 82_800 s but less than 109_680 s - user C],average_conversion_time=29_540,+ median_conversion_time=3600,),)@@ -219,6 +220,7 @@ class TestFunnelTimeToConvert(ClickhouseTestMixin, APIBaseTest):], # Reached step 1 from step 0 in at least 82_800 s but less than 109_680 s - user C],average_conversion_time=29_540,+ median_conversion_time=3600,),)@@ -318,6 +320,7 @@ class TestFunnelTimeToConvert(ClickhouseTestMixin, APIBaseTest):[82804, 0],],average_conversion_time=29_540,+ median_conversion_time=3600,),)@@ -507,6 +510,7 @@ class TestFunnelTimeToConvert(ClickhouseTestMixin, APIBaseTest):], # Reached step 1 from step 0 in at least 82_800 s but less than 109_680 s - user C],average_conversion_time=29540,+ median_conversion_time=3600,),)@@ -635,6 +639,7 @@ class TestFunnelTimeToConvert(ClickhouseTestMixin, APIBaseTest):], # Reached step 1 from step 0 in at least 82_800 s but less than 109_680 s - user C],average_conversion_time=29540,+ median_conversion_time=3600,),)diff --git a/posthog/schema.py b/posthog/schema.pyindex 3c0cf0476507..836e1ffb0712 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -1450,6 +1450,7 @@ class FunnelTimeToConvertResults(BaseModel):)average_conversion_time: float | None = Nonebins: list[list[int]]+ median_conversion_time: float | None = Noneclass FunnelTrendsResults(RootModel[list[dict[str, Any]]]):@@ -10618,6 +10619,13 @@ class CachedFunnelsQueryResponse(BaseModel):default=None,description=("Measured timings for different parts of the query generation process"),)+ total_median_conversion_time: float | None = Field(+ default=None,+ description=(+ "Median total conversion time across all completers, computed"+ " breakdown-agnostically for the Steps viz header."+ ),+ )warnings: list[DataWarehouseSyncWarning] | None = Field(default=None,description=(@@ -15721,6 +15729,13 @@ class FunnelsQueryResponse(BaseModel):default=None,description=("Measured timings for different parts of the query generation process"),)+ total_median_conversion_time: float | None = Field(+ default=None,+ description=(+ "Median total conversion time across all completers, computed"+ " breakdown-agnostically for the Steps viz header."+ ),+ )warnings: list[DataWarehouseSyncWarning] | None = Field(default=None,description=(@@ -19092,6 +19107,13 @@ class QueryResponseAlternative68(BaseModel):default=None,description=("Measured timings for different parts of the query generation process"),)+ total_median_conversion_time: float | None = Field(+ default=None,+ description=(+ "Median total conversion time across all completers, computed"+ " breakdown-agnostically for the Steps viz header."+ ),+ )warnings: list[DataWarehouseSyncWarning] | None = Field(default=None,description=(diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 0ef84eff543c..68e753c2b71f 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -2626,6 +2626,8 @@ export interface FunnelsQueryResponseApi {results: unknown/** Measured timings for different parts of the query generation process */timings?: QueryTimingApi[] | null+ /** Median total conversion time across all completers, computed breakdown-agnostically for the Steps viz header. */+ total_median_conversion_time?: number | null/** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */warnings?: DataWarehouseSyncWarningApi[] | null}diff --git a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_funnels_query_runner.ambr b/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_funnels_query_runner.ambrindex c0d2f48292f6..3e6a3f86cc0a 100644--- a/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_funnels_query_runner.ambr+++ b/products/experiments/backend/hogql_queries/test/__snapshots__/test_experiment_funnels_query_runner.ambr@@ -14,12 +14,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -93,12 +95,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -172,12 +176,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -251,12 +257,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -340,12 +348,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -429,12 +439,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -518,12 +530,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -590,12 +604,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROM@@ -662,12 +678,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,if(less(row_number, 25), breakdown, ['Other']) AS final_propFROMdiff --git a/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr b/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambrindex 67914e011da1..4e7fe9d334f4 100644--- a/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr+++ b/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr@@ -6,12 +6,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -87,12 +89,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROM@@ -166,12 +170,14 @@sum(step_2) AS step_2,arrayMap(x -> if(isNaN(x), NULL, x), [avgArrayOrNull(step_1_conversion_times)])[1] AS step_1_average_conversion_time,arrayMap(x -> if(isNaN(x), NULL, x), [medianArrayOrNull(step_1_conversion_times)])[1] AS step_1_median_conversion_time,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', arrayFlatten(groupArray(arrayFlatten(groupArray(total_conversion_times))) OVER ()))])[1] AS total_median_conversion_time,groupArray(row_number) AS row_number,final_prop AS final_propFROM(SELECT countIf(ifNull(notEquals(bitAnd(steps_bitfield, 1), 0), 1)) AS step_1,countIf(ifNull(notEquals(bitAnd(steps_bitfield, 2), 0), 1)) AS step_2,groupArrayIf(timings[1], ifNull(greater(timings[1], 0), 0)) AS step_1_conversion_times,+ groupArrayIf(arraySum(timings), ifNull(greaterOrEquals(step_reached, 1), 0)) AS total_conversion_times,rowNumberInAllBlocks() AS row_number,breakdown AS final_propFROMdiff --git a/products/product_analytics/backend/api/test/__snapshots__/test_insight_funnels.ambr b/products/product_analytics/backend/api/test/__snapshots__/test_insight_funnels.ambrindex b70b0e522c73..29bb76aa3362 100644--- a/products/product_analytics/backend/api/test/__snapshots__/test_insight_funnels.ambr+++ b/products/product_analytics/backend/api/test/__snapshots__/test_insight_funnels.ambr@@ -4,7 +4,8 @@/* user_id:0 request:_snapshot_ */SELECT bin_from_seconds,person_count,- arrayAvg(timings) AS averageConversionTime+ arrayAvg(timings) AS averageConversionTime,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', timings)])[1] AS medianConversionTimeFROM(SELECT timings AS timings,accurateCastOrNull(least(60, greatest(1, ceil(cbrt(ifNull(length(timings), 0))))), 'Int64') AS bin_count,@@ -73,7 +74,8 @@/* user_id:0 request:_snapshot_ */SELECT bin_from_seconds,person_count,- arrayAvg(timings) AS averageConversionTime+ arrayAvg(timings) AS averageConversionTime,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', timings)])[1] AS medianConversionTimeFROM(SELECT timings AS timings,accurateCastOrNull(least(60, greatest(1, ceil(cbrt(ifNull(length(timings), 0))))), 'Int64') AS bin_count,@@ -142,7 +144,8 @@/* user_id:0 request:_snapshot_ */SELECT bin_from_seconds,person_count,- arrayAvg(timings) AS averageConversionTime+ arrayAvg(timings) AS averageConversionTime,+ arrayMap(x -> if(isNaN(x), NULL, x), [arrayReduce('median', timings)])[1] AS medianConversionTimeFROM(SELECT timings AS timings,accurateCastOrNull(least(60, greatest(1, ceil(cbrt(ifNull(length(timings), 0))))), 'Int64') AS bin_count,diff --git a/products/product_analytics/backend/api/test/test_insight_funnels.py b/products/product_analytics/backend/api/test/test_insight_funnels.pyindex 1cba25b015b0..041c24e98eb5 100644--- a/products/product_analytics/backend/api/test/test_insight_funnels.py+++ b/products/product_analytics/backend/api/test/test_insight_funnels.py@@ -270,6 +270,7 @@ class ClickhouseTestFunnelTypes(ClickhouseTestMixin, APIBaseTest):"result": {"bins": [[2220, 2], [42510, 0], [82800, 1]],"average_conversion_time": 29540,+ "median_conversion_time": 3600.0,},},)@@ -329,6 +330,7 @@ class ClickhouseTestFunnelTypes(ClickhouseTestMixin, APIBaseTest):"result": {"bins": [[2220.0, 2], [42510.0, 0], [82800.0, 1]],"average_conversion_time": 29540.0,+ "median_conversion_time": 3600.0,},},)@@ -388,6 +390,7 @@ class ClickhouseTestFunnelTypes(ClickhouseTestMixin, APIBaseTest):"result": {"bins": [[2220.0, 2], [42510.0, 0], [82800.0, 1]],"average_conversion_time": 29540.0,+ "median_conversion_time": 3600.0,},},)diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 9edc39bb2732..efe6d4b62237 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -1963,6 +1963,8 @@ export interface FunnelsQueryResponseApi {results: unknown/** Measured timings for different parts of the query generation process */timings?: QueryTimingApi[] | null+ /** Median total conversion time across all completers, computed breakdown-agnostically for the Steps viz header. */+ total_median_conversion_time?: number | null/** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */warnings?: DataWarehouseSyncWarningApi[] | null}diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 11b681124f65..526f915e4724 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -2698,6 +2698,8 @@ export namespace Schemas {results: unknown;/** Measured timings for different parts of the query generation process */timings?: QueryTiming[] | null;+ /** Median total conversion time across all completers, computed breakdown-agnostically for the Steps viz header. */+ total_median_conversion_time?: number | null;/** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */warnings?: DataWarehouseSyncWarning[] | null;}@@ -45440,6 +45442,8 @@ export namespace Schemas {results: unknown;/** Measured timings for different parts of the query generation process */timings?: QueryTiming[] | null;+ /** Median total conversion time across all completers, computed breakdown-agnostically for the Steps viz header. */+ total_median_conversion_time?: number | null;/** Warnings about data warehouse sources referenced by the query whose latest sync failed, is paused, hit a billing limit, or is otherwise stale. Results may not reflect current source data. Accumulated across every HogQL execution that contributes to this response — so insights backed by warehouse tables (Trends, Funnels, etc.) receive the same warnings as raw HogQL queries. */warnings?: DataWarehouseSyncWarning[] | null;}