How can I make a conditional aggregation field using Google data studio's calculated fields?
In the example above - I want to calculate the median only for users with at least one account (accounts > 0)
Two options I can think of.
ONE: You can use CASE statements in your field. But first, you will need to create a new field to only include accounts > 0. Anything that doesn't meet the criteria becomes "null".
New_field:
CASE
WHEN accounts > 0 THEN accounts
END
Then create another field that takes the MEDIAN of the new_field:
MEDIAN(new_field)
TWO: Another option if it's for a visualization, you can create your normal field
MEDIAN(accounts)
but then you will need add a filter (in the data option tab) in your visualization with the condition:
INCLUDE Field="accounts" condition= "Greater Than" Value="0"