Knowledge Drop

Creating hour / minute durations in visualisations with value_format [value format]


Userlevel 1

Last tested: Nov 25, 2019
 

If you want to represent durations in hours, minutes and seconds in a visualisation, you can do this by representing the duration as a fraction of a day, and applying [h]:mm:ss in the 'value_format' section of the visualisation settings.

Value_format example.png

This can also be done with some HTML formatting in the LookML, here is an example:
dimension_group: elapsed {

type: duration

sql_start: ${dep_raw} ;;

sql_end: ${arr_raw} ;;

timeframes: [second,minute,hour]

}

 

dimension: elaped_formatted {

type: number

sql: ${seconds_elapsed} ;;

html: {% assign h = {{value}} | divided_by: 3600 %}{% assign m = minutes_elapsed._value | modulo: 60 %}{% assign s = seconds_elapsed._value | modulo: 60 %}{{h}}h{{m}}m{{s}}s;;

}

 

This content is subject to limited support.                

 

 


0 replies

Be the first to reply!

Reply