Median of total grouped by column filtered by timestamp interval

I have a table consisting of three columns:

  1. Timestamp
  2. User ID
  3. Revenue

I want to create a visualization that, when a timestamp interval filter is selected, will return the median of total revenue grouped by user during that time period.
 

Here’s a toy example of the source table:

Timestamp User ID Revenue
1/1/2022 1 $10.00
1/1/2022 2 $15.00
1/2/2022 1 $12.00
1/3/2022 1 $5.00
1/3/2022 2 $15.00
1/3/2022 3 $30.00
1/3/2022 4 $35.00
1/4/2022 2 $5.00
1/4/2022 3 $10.00
1/5/2022 5 $10.00
1/6/2022 1 $10.00
1/6/2022 2 $15.00

If the timestamp filter was set to ‘past 5 days’, the visualization would return $37.00, 
that is, the median of: 

User ID Total Revenue During Interval
1 $37.00
2 $50.00
3 $40.00
4 $35.00
5 $10.00

If the timestamp filter was set to 1/3/2022-1/5/2022, the visualization would return $20.00, that is the median of:

User ID Total Revenue During Interval
1 $17.00
2 $20.00
3 $40.00
4 $35.00
5 $10.00

If the timestamp filter was set to < 1/4/2022, the visualization would return $32.50, that is the median of:
 

User ID Total Revenue During Interval
1 $27.00
2 $30.00
3 $60.00
4 $35.00

The issue is that the median cannot be calculated until the totals are calculated and the totals cannot be calculated until the time interval is selected. I’ve tried doing this with a ‘calculation’ column, however, the resulting table containing user totals contains far more than 5000 rows and thus, throws off the median calculation.

0 0 183
0 REPLIES 0
Top Labels in this Space
Top Solution Authors