I am new to Looker and I am trying to show the median value by day. If I have the following data, how would I calculate the median of all values for each day? My goal is to display a bar chart with a single median value for each day.
Date
Record
Value
10/1/2021
1
5
10/1/2021
2
8
10/1/2021
3
9
10/2/2021
4
10
10/2/2021
5
10
10/2/2021
6
4
10/2/2021
7
5
My goal is to get an output that displays the following for each day:
Thank you. I should have specified that I am trying capture the median from a table calculation I created. The simple table calc is a diff function between start date and stop date for each record. My goal is to calculate the daily median value for these listed records.
I had thought that I could pivot the dates in order capture the median value of each Start-Stop calc at the date level but I am unable to do so.
You’re trying to get a daily-level results but the granularity of your data is not at a daily-level, that’s why you can’t do it. In normal SQL, you would be able to use Window Functions and even though Date is repeated, it would hold the same value.
This is much easier to achieve in LookML because everything you need is already built. You can create dimension duration_minute and feed this dimension your sql_start and sql_end, then add a measure median_duration.
Then in your explore all you have to do is select date + that measure. Your granularity is on date level, which means you will get one row per date, and all calculations are done in the background