Question

How to use median function after summing a measure at different levels?

  • 22 August 2019
  • 3 replies
  • 1592 views

Hi,

I am using one measure named games_won at pid(user_id),date, mode, bucket level. If I directly use median it will give me data at this level only. But how can I use median function in this if I have to find at mode level only or bucket level only or maybe filter some buckets out? Because now first I have to sum it up at mode level then I have to find median.


3 replies

Userlevel 3

You can do this with a median measure in Looker, where the results table has one row per mode or date or bucket level or combination of some number of those. The median will be taken per mode as desired.

So Currently, I have this dataset.

27%20AM

If I have to find the median for this, it will come out as 6.5.

Now, Let’s say I want to find the median for all the buckets, So I have now aggregated it at mode, pid level. Now my new dataset will look like this.


pid mode Games played

2 rummy 19

3 normal 3

4 normal 6

4 poker 13

4 rummy 19

5 poker 7

and median for this new one is 10.

So I don’t think going with only the median measure will work here.

Userlevel 3

That’s because you’re taking the sum of games played as your third column. I meant that you should take the median instead. But perhaps I’m misunderstanding what you seek.

Reply