DAX - Grand Average of Count

JB2020

Board Regular
Joined
Jul 29, 2020
Messages
88
Office Version
  1. 365
  2. 2016
  3. 2010
Platform
  1. Windows
I am looking to create a measure to show a grand average of the number of occurrences of each date in the Data table, to display in a chart. I have provided an example below, please let me know if you need more information though. Any help is appreciated.

Calendar Table
Date
01/01/2020​
02/01/2020​
03/01/2020​

Data Table
Dates
01/01/2020​
01/01/2020​
02/01/2020​
02/01/2020​
02/01/2020​
03/01/2020​
03/01/2020​
03/01/2020​
03/01/2020​

Desired result

DateCountGrand Average
01/01/2020​
2​
3​
02/01/2020​
3​
3​
03/01/2020​
4​
3​

1607429220336.png
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
There must be a better way, but this seems to work:

=CALCULATE(AVERAGEX(Data,COUNTX(VALUES('Calendar'[Date]),[Dates])),ALL('Calendar'[Date]))
 
Upvote 0
I don't know if this is more efficient or not, but you could also use:

=AVERAGEX(SUMMARIZE(ALL(Data),Data[Dates],"DateCount",COUNT([Dates])),[DateCount])
 
Upvote 0
Solution
I don't know if this is more efficient or not, but you could also use:

=AVERAGEX(SUMMARIZE(ALL(Data),Data[Dates],"DateCount",COUNT([Dates])),[DateCount])
Works great, Thanks Rory
 
Upvote 0
I don't know if this is more efficient or not, but you could also use:

=AVERAGEX(SUMMARIZE(ALL(Data),Data[Dates],"DateCount",COUNT([Dates])),[DateCount])
I had a bit of a play around with this today and here's what I came up with in the end:

=COUNTROWS(ALLSELECTED(Data))/COUNTROWS(ALLSELECTED(Calendar))

Just a quick follow up if you are able to offer any advice on this also? My data contains dates for 2019 and 2020 and is currently filtered for dates only in 2020. I have a measure which shows the count of Dates for the same weekday last year (Date - 364). Is there a way to create a grand average for these also, like the measure above? |So basically I need it to count all rows in the Data table where the date = all selected dates - 364.
 
Upvote 0

Forum statistics

Threads
1,223,754
Messages
6,174,313
Members
452,554
Latest member
Louis1225

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top