The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I would like to calculate the average per day for each month for the following measure.
With the average calculation above it gives the following results which are not what I want.
Solved! Go to Solution.
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.
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.
The below is a screenshot of the table tblHolidayDates_all locations
and the below is a screenshot of the table Calendar
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
This is Calendar
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
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
User | Count |
---|---|
77 | |
75 | |
36 | |
31 | |
29 |
User | Count |
---|---|
93 | |
81 | |
57 | |
48 | |
48 |