Dynamically Change date field in an explore based on the Drill into level

Good day experts. What I need today is on another level. So easy and simple of the surface, but very complicated and difficult when digging in it.

I have a chart, that contains 1 dimension (year_quarter), and 4 metrics: exp1, exp2, exp3 and exp4. We need to see the data at multiple levels:

 

I created a drill field set having the first column "year_quarter" and I am exploring the data at this level. Now the client requested a drill into functonality, enabling them to see data at "year_month" and "year_week", also having the same explore set. it means same details about the data from quarter to month to week.
To have a dynamic behavior, we can use the same drill field set but we can change the first column to be year_month or year_week instead of year_quarter anytime we drill into these level. it means if I drilled into year_month level, when exploring the data, the year_quarter should be replaced by year_month (also the label should change as well). This is in summary the issue that I am facing: I am not able to dynamically replace the year_quarter with year_month or year_week according to the drill into level. I tried to use parameters, templated filters, anything that I found but nothing worked. The drill set should automatically detect at what level it is now and display the data accordingly.

I tried to do this and many other things but nothing worked.

dimension: year_quarter {
type: string
sql: ${TABLE}.YEAR_QUARTER ;;
drill_fields: [year_month, year_week]
}

parameter: year_quarter_month_week {
type: unquoted
allowed_value: {
label: "Year Quarter"
value: "year_quarter"
}
allowed_value: {
label: "Year Month"
value: "year_month"
}
allowed_value: {
label: "Year Week"
value: "year_week"
}
default_value: "year_quarter"
}


dimension: date_hierarchy {
label_from_parameter: year_quarter_month_week
type: string
sql: ${TABLE}.{% parameter year_quarter_month_week %} ;;
}

To note that I am trying to make the work dynamically and not create different drill sets for each level cz this will cause lot of redundant code and with be a nightmare.

Can you please help me identify how we can set the first field of the drill field set dynamically without duplicating the code?

Jihad_0-1691765564714.png

Thank you

 

0 0 73
0 REPLIES 0
Top Labels in this Space
Top Solution Authors