Use filter attribute to calculate user value

Hi everyone.

One of the data columns that I need to display in looker is calculated using the end_date of the chosen period. So my intention is to allow the user to filter choosing the last date ( or maybe a date range ) from a period. With the last date of this period the value of my column would change, something like ( active, inactive ), this value is being calculated using table calculations.

I would like to know if there is any way to get the value of the filter to use in my table calculation?

Solved Solved
0 2 1,696
1 ACCEPTED SOLUTION

I was able to solve this problem today, will share the solution that might help someone in the future. Btw, I think that the title of this question don't really describes the problem, but I wasn't able to change it.

I left the idea of using parameters aside, and used liquid variables to solve the issue.

dimension: state {
type: string
sql:
CASE
WHEN
${view_name.start_date} IS NULL OR
COALESCE({% date_end filter_field_name %}, TIMESTAMP(CURRENT_DATE())) < ${view_name.start_date} THEN 'Inactive'
ELSE
'Inactive'
END ;;
}

where  this {% date_end filter_field_name %} is used to get the end date of my filter.

This will change the value from state depending on the last date of my filter. For now, seem like it's only working with date ranges, but is enough for my current problem.

Not sure if there is a better way of doing this, but if you know a better way, please share with me 🙂

View solution in original post

2 REPLIES 2
Top Labels in this Space