Dynamic label. Get name from other dimension

Hi everyone

I was wondering if it's possible to define a label in a measure from the value string calculated in another dimension

dummy example:

dimension: cost_first_month_label{
type: string
sql: CASE WHEN ${TABLE}.date_month = X THEN ${TABLE}.date END ;;
}

Imagine that returns the current month ie: January 2025, and I want to use this string as label from a measure:

measure: cost_first_month{
type: number
label: field ${cost_first_month_label}
 sql: CASE WHEN ${TABLE}.Order_Q = 1 THEN ${TABLE}.Cost END ;;
}

 

Thanks!

 

0 2 180
2 REPLIES 2

You can use Liquid to dynamically change field names, as seen here. I've never tried it for a use case like this though!

Hey @Rub_moy !
In your case you are expecting a result from a query that you're running to define the name of a measure.
This is imposible for now in Looker as far as I know as the labels load without any query on the menu. 
The full reference about Liquid, I recommend you to check this site:
https://cloud.google.com/looker/docs/liquid-variable-reference
Although you can see from the whole website, that all of them are applied after a query was run, not before which will be needed in order to have it as label to appear on the Explore.
If you would like to share a little bit more about the use case so I can see if there is a workaround for the viz, happy to help further.
Hope this helped you to understand the issue and why you didn't find a way.

Kind regards,
Desi 😊

Top Labels in this Space
Top Solution Authors