Point to one or another table based on date filter

Hi!

I have two tables on BQ, one table has the historical information (< 2022) and the other has actual information (>= 2022).

I’m trying to create a Liquid sentence on the sql_table_name parameter inside the view, so the query use one table or another, based on the date filtered.

This is the sentence I made that doesn’t work:

sql_table_name: `project.dataset.{% if lkp_dates.date._is_filtered and lkp_dates.date < "2022-01-01 00:00:00" %}fct_historical_data{% else %}fct_actual_data{% endif %}` ;;

I notice that the sentence works when I use only the _is_filtered parameter, but I can’t make it work when I want to apply the date.

Do you have any idea on how to make it work?

Thanks!

2 1 233
1 REPLY 1

I want to update. I tried something like this but still doesn’t work:

{% if lkp_dates.date._is_filtered %}

    {% assign date1 = "2023-01-01 00:00:00" | date: "%s" | minus: 0 %}

    {% assign date2 = fct_transac_dinamica_prueba.filter_end | date: "%s" | minus: 0 %}

        {% if date2 < date1 %}

        fct_historical_data

        {% else %}

        fct_actual_data

        {% endif %}

{% else %}

fct_actual_data

{% endif %}

This is working with these two dimensions in addition to the DATE dimension:

  dimension: filter_start {

    type: date

    sql: {% date_start lkp_dates.date %} ;;

  }

  

  dimension: filter_end {

    type: date

    sql: {% date_end lkp_dates.date %} ;;

  }

Top Labels in this Space
Top Solution Authors