How to set up an aggregation year filter and switch the data acquisition year for the entire dashboard at once

We would like to know if you have any ideas on how to implement the requirements in the following prerequisites.

1. requirements
I would like to set up a single filter on the dashboard to switch the year of aggregation, and then switch the year of aggregation for each Tile at once according to the selected year.

2. prerequisite
In the dashboard, there exists Tile A generated from Explore A and Tile B generated from Explore B.
Explore A refers to TABLE_A and Explore B refers to TABLE_B.
In addition, TABLE_A and TABLE_B have data archived by year, respectively, and the following archive tables exist.

  • TABLE_A_2022
  • TABLE_A_2021
  • TABLE_B_2022
  • TABLE_B_2021

3. implementation method considered
Define the aggregation year as a parameter and set up an aggregation year filter on the dashboard.
Switch the reference of sql_table_name according to the selected year.

view: view_A {
sql_table_name:
{% if aggregate_year._parameter_value == '2021' %}
`project_name.dataset_name.TABLE_A_2021`
{% else if aggregate_year._parameter_value == '2022' %}
`project_name.dataset_name.TABLE_A_2022`
{% else %}
`project_name.dataset_name.TABLE_A`
{% end if %} ;;

parameter: aggregate_year {
type: string
label: "aggregate year"
allowed_value: {
label: "Year 2023"
value: "2023"
}
allowed_value: {
label: "Year 2022" value: "2022" }
value: "2022" }
}
} allowed_value: {
label: "Year 2021" value: "2021" }
value: "2021" }
}
}
}
}

※Define the same parameters for view_B, and make sql_table_name branch according to aggregate_year.

This method was found to be NG in LookML syntax.
When adding a branching process to sql_table_name, if a parameter is involved, it is NG in the specification.

4. reference
The following implementation method does not meet the requirements.
This is because it requires a dedicated filter for view_B, and multiple aggregate year filters must be installed in the dashboard.
The point of this requirement is to use one aggregate year filter to switch the year of Tiles generated from multiple Explore at once.

view: view_A {
    sql_table_name: {% parameter aggregate_year %};;

    parameter: aggregate_year {
        type: unquoted
        label: "aggregate year"
        allowed_value: {
            label: "Year 2023"
            value: "project_name.dataset_name.TABLE_A"
            }
        allowed_value: {
            label: "Year 2022" value: "project_name.dataset_name.
            value: "project_name.dataset_name.TABLE_A_2022" }
            }
        } allowed_value: { label: "Year 2021" value: "project_name.dataset_name.
            label: "Year 2021" value: "project_name.dataset_name.
            value: "project_name.dataset_name.TABLE_A_2021" }
            }
    }
0 1 72
1 REPLY 1

※日本語でも書いておきます。

下記の前提条件にある要件を、実現するためのアイデアがあれば教えて頂きたいです。

1. 要件

ダッシュボードに集計年度を切り替えるフィルタを一つ設置し、選択した年度に応じて各Tileの集計年度を一括で切り替えたい

2. 前提条件

ダッシュボード内には Explore A から生成する Tile A と Explore B から生成する Tile B が存在し、Explore A は TABLE_A を参照しており、Explore B は TABLE_B を参照しているとする。

また、TABLE_A と TABLE_B はそれぞれ年度ごとにデータがアーカイブされており、下記のアーカイブテーブルが存在する。

  • TABLE_A_2022
  • TABLE_A_2021
  • TABLE_B_2022
  • TABLE_B_2021

3. 検討した実装方法

集計年度をパラメータとして定義し、ダッシュボード上に集計年度フィルタを設ける。

選択した集計年度に応じて、sql_table_nameの参照先を切り替える。

view: view_A {
sql_table_name:
{% if aggregate_year._parameter_value == '2021' %}
`project_name.dataset_name.TABLE_A_2021`
{% else if aggregate_year._parameter_value == '2022' %}
`project_name.dataset_name.TABLE_A_2022`
{% else %}
`project_name.dataset_name.TABLE_A`
{% end if %} ;;

parameter: aggregate_year {
type: string
label: "aggregate year"
allowed_value: {
label:"Year 2023"
value:"2023"
}
allowed_value: {
label:"Year 2022"
value:"2022"
}
allowed_value: {
label:"Year 2021"
value:"2021"
}
}
}

※ view_Bも同じパラメータを定義し、sql_table_nameをaggregate_yearに応じて分岐させる

この方法はLookMLの文法上NGであることが判明。

sql_table_nameに分岐処理を追加する際に、パラメータを絡めると仕様上NGのため。

4. 参考

下記の実装方法は要件を満たしません。

なぜなら、view_B専用のフィルタを別途設置する必要があり、ダッシュボード内に複数の集計年度フィルタを設置する必要があるためです。

今回の要件のポイントは、一つの集計年度フィルタで、複数のExploreから生成されるTileの年度を一括して切り替えることです。

view: view_A {
sql_table_name: {% parameter aggregate_year %};;

parameter: aggregate_year {
type: unquoted
label: "aggregate year"
allowed_value: {
label:"Year 2023"
value:"project_name.dataset_name.TABLE_A"
}
allowed_value: {
label:"Year 2022"
value:"project_name.dataset_name.TABLE_A_2022"
}
allowed_value: {
label:"Year 2021"
value:"project_name.dataset_name.TABLE_A_2021"
}
}
Top Labels in this Space
Top Solution Authors