Dimension using GROUP BY from View

Hi all, I have a

view: my_app {

dimension: time { #… }
dimension: device_id { #… }
dimension: todo {

SELECT sum(time) FROM my_app GROUP BY device_id

}
}

I would like to ask how I can format the SELECT statement above using LookML.

Thank you for your help!

You don’t really have to format it at all. If you create a measure of type sum then when you select device_id in your Look/Explore, the measure will be aggregated to the appropriate level. The timension time has to be a number of course for this to work.

measure: todo {
    type: sum
    sql: ${time} ;;
    value_format: 
}

I added value_format in case you want to format the measure in specific way.

1 Like

Thank you very much Dawid for your answer.

I was so caught up with figuring out grouping device_id in LookML that I forgot it could be selected in the Explore page.

You have helped me solved this, thank you very much once again!

1 Like

Solved, thank you.

1 Like