Hello,
Does anyone has experience in writing lookml code which is able to capture value of template filter (I would like to use date range entered by the user) ?
Link from web about template filter value and using it in conditions: https://cloud.google.com/looker/docs/templated-filters#templated_filters
After capturing the template filter value have you also used this in some if/case statements ? The two statements I want to apply :
1. If the period selected in template filter is less then 25 full weeks please use 25 full weeks starting from the end_ date value entered to template filter.
2. If the period selected in the template filter is more then 25 full weeks please use period selected by the user.
Thanks.
I believe you can achieve this by using `date_start` and `date_end` with date filters. Below is an example:
# Define a filter
filter: date_filter {
type: date
}
SELECT
*
FROM
your_dataset.your_table
WHERE
CASE
WHEN DATE_DIFF(DATE_ADD({% date_end date_filter %}, INTERVAL 1 DAY), {% date_start date_filter %}, WEEK) < 25
THEN your_table.date_column BETWEEN DATE_SUB(DATE_ADD({% date_end date_filter %}, INTERVAL 1 DAY), INTERVAL 25 WEEK) AND {% date_end date_filter %}
ELSE your_table.date_column BETWEEN {% date_start date_filter %} AND {% date_end date_filter %}
END;