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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jlkbi
New Member

Creating a YTD Daily Average Measure

Hello!

I am having a tough time wrapping my head around the steps necessary to create a DAX measure to capture YTD daily averages with the information below:

 

jlkbi_0-1631811929092.png

 

Because each month contains a different number of days, simply dividing by # of MTD isn't correct. Thanks for your assistance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

You want to use the Day of Year calculation from this answer: https://community.powerbi.com/t5/Desktop/Day-number-of-year-DAX/m-p/338657/highlight/true

 

Then sum your Monthly Avg. Impressions and divide it by the Day of Year calculated result.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

You want to use the Day of Year calculation from this answer: https://community.powerbi.com/t5/Desktop/Day-number-of-year-DAX/m-p/338657/highlight/true

 

Then sum your Monthly Avg. Impressions and divide it by the Day of Year calculated result.

Thanks! This was the missing piece I believe.

 

Would you know how to modify the Day of Year calculation to account for a Fiscal Year (e.g., Jul - Jun)?

Anonymous
Not applicable

Hmm, good question. I think you might want to use the DATESBETWEEN function instead: https://docs.microsoft.com/en-us/dax/datesbetween-function-dax Then specify the start date as your start of fiscal year.

 

Try something like this:

 

Day of the Fiscal Year = COUNTROWS(DATESBETWEEN('Dates'[Date].[Date],DATE(2021,7,1),TODAY()))
TomMartens
Super User
Super User

Hey @jlkbi ,

 

please provide the business rule you want to apply, another question: Do you use a dedicated Calendar table, or does your data model only consists of one table?

What is "Avg Daily Impression", is it a measure?

 

I assume the Feb YTD Avg is something divided by 59 (31 days in January + 28 days in February).

 

Regards,
Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thank you. I have a dedicated calendar table.

 

Avg Daily Impression is value from our system. I can use a measure incorporating a Days Measure 

DAY ( EOMONTH ( MIN ( 'Date'[Date] ), 0 ) ) to give me a monthly total. Using this, I can figure out the total transactions for a multi-month period. In your above example, through FEB, there were 302,186,495 impressions (161,245,415 in 31 Jan days and 140,941,080 in 28 Feb days). Dividing that total by 59 YTD days gets me the correct daily average...I suppose I am stuck on how to then correctly calculate the correct YTD days for any specific period (especially if LEAP years are involved).
amitchandak
Super User
Super User

@jlkbi , You are showing month data here.

If you need avg to daily sum

measures 

Daily Impression = sum(Table[Value]) //or count(Table[Value])

Avg Daily Impression = AverageX(Values('Date'[Date]), [Daily Impression])

 

YTD avg = CALCULATE([Avg Daily Impression],DATESYTD('Date'[Date],"12/31"))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Thank you!

Avg Daily Impression is value from our system. It is displayed monthly, that's correct.  I can use a measure incorporating a Days Measure 

DAY ( EOMONTH ( MIN ( 'Date'[Date] ), 0 ) ) to give me a monthly total. Using this, I can figure out the total transactions for a multi-month period.
 
Using your YTD measure however appears to take all of the transaction totals for each month and divides by the number of months in the YTD. Because each month has a different number of days, this doesn't provide the accurate answer for daily averages (in other words, it treats the daily average from 31 days in January with the same weight as 28 days in February).

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.