Forum Discussion
rogerdea
Helper IV
7 years agoAverage days between dates and locations
I've seen a few topics on this but nothing specific to what i am trying to achieve. What i am trying to do is, for each location in my data, measure the average number of days between dates for e...
- 7 years ago
rogerdea Give this a try. You will need to change the name of your table in the measure.
Avg Days in Location = AVERAGEX ( VALUES ( 'Table'[Location] ), CALCULATE( DIVIDE ( DATEDIFF ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ), DAY ), COUNTROWS ( 'Table' ) -1 ) ) )
Mariusz
Community Champion
7 years agoHi rogerdea
Can explain the logic behind thous figures.
Telford 5.4 days
Bournemouth 8.1 days
London 9.1 days
Thanks
Mariusz
rogerdea
Helper IV
7 years agoThe figures were just an example not the expected results, i was just showing how the table would look, rather than the actual averages. I dont have the answer.. yet!
- jdbuchanan717 years ago
Super User
rogerdea Can you give us the actual expected result for the data in your screenshot?
- rogerdea7 years ago
Helper IV
Sure i have just worked them out manually in excel and the results are:
Telford = 21
London = 26.6
Bournemouth = 30
Thanks
- jdbuchanan717 years ago
Super User
rogerdea Give this a try. You will need to change the name of your table in the measure.
Avg Days in Location = AVERAGEX ( VALUES ( 'Table'[Location] ), CALCULATE( DIVIDE ( DATEDIFF ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ), DAY ), COUNTROWS ( 'Table' ) -1 ) ) )