Hi everyone,
I am trying to be able to get the result from a dimension in a view and use it as a value in a derived table using liquid.
I've got two date type dimensions that help me to define the start and the end of the dates of the comparison period. Let's say, if users select the year 2024 and wants to compare with previous year:
period_2_start = 2023-01-01
period_2_end = 2023-12-31
Since I already have those 2 fields calculated, im trying to use them to filter the derived table like this:
{%- if pop_method.compare_to._in_query -%}
OR ${pop_method.select_base_date_date} between period_2_start and period_2_end
{%- endif -%}
This is the an example of how my derived table would look like
I've been able to use liquid to pass some filters and parameters to my derived table but I haven't been able to do the same with a dimension.
view: Test {
derived_table: {
sql:
SELECT
orders
,sum(total_sales)
FROM
test_db
where
({%- if pop_method.current_date_range._is_filtered -%}
{% condition pop_method.current_date_range %} departuredate {% endcondition %}
{%- if pop_method.compare_to._in_query -%}
OR ${pop_method.select_base_date_date} between X and Y
{%- endif -%}
{%- else -%}
1 = 1
{%- endif -%})
{% if ppi.bun_name._is_filtered %}
AND {% condition pppi.bun_name %} bun_name {% endcondition %}
{% endif %}
{% if pppi.bgv_name._is_filtered %}
AND {% condition pppi.bgv_name %} bgv_name {% endcondition %}
{% endif %}
I've read multiple post but I can't find the answer:https://www.googlecloudcommunity.com/gc/Technical-Tips-Tricks/Advanced-LookML-Liquid-Use-Cases/ta-p/...
Could someone shed light on this issue? Thanks in advance! 🙂