Solved

Median query not working

  • 10 August 2022
  • 4 replies
  • 39 views

Hi, 

I have a set of conversations logged in with DATE attribute. I’d like to measure the median count of conversation per day. 

However, when I enter something like 
 

SELECT MEDIAN(COUNT(conversation_id)) BY Date (Start Date)

it doesn’t seem to work, and instead give me the total count, not the median count by date. Am I missing something? How could I get the median count of conversations? Thanks so much

icon

Best answer by Moises Morales 10 August 2022, 20:01

View original

4 replies

ooooooh okay it works now. Thanks so much!

Userlevel 3

This will depend on how is your LDM is structured, but it’s possible to get the  median of an attribute count by certain date with a compound metric, i.e.: 

Metric “Count”:

SELECT COUNT (Customer Id) BY Month/Year (Date)

 

Metric “Median”:

SELECT MEDIAN (COUNT)

 

Hi Moises, that makes sense. 

But then, how can I write a MAQL query to get the median number of all the ‘rows’ in my LDM across one dimension? 
(e.g., the number of ‘rows’ across Date) ? 

Userlevel 3

Hi Emmanuel, 

 

This is because the COUNT function returns the number of unique values of an attribute within the given context. All the unique attributes values are counted as ‘1’ when using COUNT, therefore calculating the median for them does not make much sense. 

 

You can check the below documentation as a reference: 

 

https://help.gooddata.com/pages/viewpage.action?pageId=86788073

https://help.gooddata.com/pages/viewpage.action?pageId=86788072

Reply