Caculate daily average

mig17
New Member

Hello everyone.

So I found this is a recurrent question here on Looker Community, but I simply cannot make it work.

I want to calculate the daily average value for a certain metric.

I have to calculated the difference between two date variables and obtain the variable “Time difference in hours”,

Then my data looks something like this:

Date             | Time difference in hours

27-03-2021 | 5

27-03-2021 | 7

27-03-2021 | 8

26-03-2021 | 10

26-03-2021 | 12

Now I want to have the data like this:

Date             | Mean (Time difference in hours)

27-03-2021 | 6,66

26-03-2021 | 11

How do I do this?

Thank you !

Solved Solved
0 4 3,794
1 ACCEPTED SOLUTION

If it’s a field that will get used rather often, you can consider moving it to the LookML and use dimension_group of type: duration

It would automatically  create the durations with easy to read way, and then you could add a measure.

https://docs.looker.com/reference/field-params/dimension_group

Here is a good example, which I think would fit your purpose:

ffa875fe-5c99-47cf-8bab-372dedf41ddb.png

View solution in original post

4 REPLIES 4
Top Labels in this Space
Top Solution Authors