Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
madlfc87
Helper I
Helper I

Average per day by month

Hello,

 

I would like to calculate the average per day for each month for the following measure.

 

Days Test = COUNTX(ADDCOLUMNS(GENERATE('tblHolidayDates_all locations',DATESBETWEEN('Calendar'[Calendar Date],'tblHolidayDates_all locations'[StartDate],'tblHolidayDates_all locations'[EndDate])),"period",MAXX(FILTER('Calendar','Calendar'[Calendar Date]=EARLIER('Calendar'[Calendar Date])),'Calendar'[Year])),[period])
 
I tried the below but I believe it averages over all the rows of the month not all the days.

 

Average Days = AVERAGEX('tblHolidayDates_all locations',[Days Test])
 
For example I have the below table
 
madlfc87_0-1727267783227.png

 

With the average calculation above it gives the following results which are not what I want.

 

madlfc87_1-1727267828043.png

 

 What I need for example is for January Average to be 53 / 31(the number of days in January) = 1.70
 
Link to my pbix file.
 
 
Appreciate your help.
 
Thank you
 
 
1 ACCEPTED SOLUTION

I will ignore these first couple rows?

 

lbendlin_0-1727476453345.png

 

lbendlin_1-1727477031217.png

lbendlin_2-1727477734416.png

 

View solution in original post

8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hi,

Revise the measure to

Days Test = DIVIDE(COUNTX(ADDCOLUMNS(GENERATE('tblHolidayDates_all locations',DATESBETWEEN('Calendar'[Calendar Date],'tblHolidayDates_all locations'[StartDate],'tblHolidayDates_all locations'[EndDate])),"period",MAXX(FILTER('Calendar','Calendar'[Calendar Date]=EARLIER('Calendar'[Calendar Date])),'Calendar'[Year])),[period]),COUNTROWS('Calendar'))

Hope this helps.

Ashish_Mathur_0-1727491832785.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

but I believe it averages over all the rows of the month not all the days.

Add an intermediate step with SUMMARIZE or SUMMARIZECOLUMNS that pre-aggregates your data by day.

Thank you for your reply. Could you be a bit more specific please?

Please provide a smaller sample file. Yours is way too big.

@lbendlin 

The below is a screenshot of the table tblHolidayDates_all locations

 

madlfc87_0-1727326537711.png

 

and the below is a screenshot of the table Calendar

 

madlfc87_1-1727326673946.png

Appreciate your help

Touche.  I should have specified that I cannot work with screenshots. Please provide sample data that fully covers your issue but not more, in a usable format.
Please show the expected outcome based on the sample data you provided.

 

This is tblHolidayDates_all locations

https://docs.google.com/spreadsheets/d/1oMMfpBywHQkPqwIhLZs-eCLLqw4LbPSy/edit?usp=sharing&ouid=11352...

 

This is Calendar

https://docs.google.com/spreadsheets/d/1Lp4bKhQqtMXo1GKb7AlWARMz2p6FLYrS/edit?usp=sharing&ouid=11352...

 

This calculates the days in every month

 

Days Test = COUNTX(ADDCOLUMNS(GENERATE('tblHolidayDates_all locations',DATESBETWEEN('Calendar'[Calendar Date],'tblHolidayDates_all locations'[StartDate],'tblHolidayDates_all locations'[EndDate])),"period",MAXX(FILTER('Calendar','Calendar'[Calendar Date]=EARLIER('Calendar'[Calendar Date])),'Calendar'[Year])),[period])

 

I want the average of Days Test per day by month. For example if the output for the days is 

madlfc87_0-1727415253428.png

 

I would like for January the Site Service average to be 53/31 = 1.70, February 64/28=2.29 and so on. If I do Average Days = AVERAGEX('tblHolidayDates_all locations',[Days Test]) it gives me a different result which I believe it averages the days over how many rows are in the specific month not the total days of the month.

 

Thank you

 

I will ignore these first couple rows?

 

lbendlin_0-1727476453345.png

 

lbendlin_1-1727477031217.png

lbendlin_2-1727477734416.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.