Hello all I am trying to create a calculated field that calculates avg Distance depending on the user’s selection i.e Daily avg, weekly avg, monthly avg and yearly avg. I tried this with no success
CASE [Frequency]
WHEN “Daily” THEN window_avg(distance, 1, “days”)
WHEN “Weekly” THEN window_avg(distance, 7, “days”)
WHEN “Monthly” THEN window_avg(distance, 30, “days”)
END
there are window function for average to calculate (avgOver()) as well as a function to truncate date to the period you specify(truncDate()). so if you could use those functions, I think you can calculate the average for the prriod. the below example is for ‘Weekly’
avgOver(distance,[truncDate(“WK”,[your date field)],PRE_FILTER)
the selection part for the period can be done by using parameter. the below dashboard shows how to use truncDate() with parameter.