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
bigmona89
Frequent Visitor

Calculate Month to Date Average Production for Current Month

Hi All!

 

I have been banging my head against the wall trying to figure out the DAX expressions to caculate a month to date average. I am relatively new to Power BI and I am absolutely loving it, but there is a bit of a learning curve for me.

 

I have tried the AverageX function so many times but can't seem to make it work for what I need. Essentially what I am trying to do is create a month to date average for the current month. So, for example, if my dataset is a rolling 30 days (lets say 11/15/2021 - 12/15/2021) I would want to calculate the MTD average production per day for 12/1 - 12/15. So it would be Total Production for Current Month  / number of days passed in current month = MTD Daily Average

 

However, once another day passes and the dataset changes to 11/16/2021 - 12/16/2021 I wouldn't want the dax expression to be static. It should know to include the new day into the calculation (month to date average for 12/1 - 12/16). Could someone point me in the right direction as to what expression to use? I am so lost. Thanks a ton! I've attached an excel table with mock data. 

 

DateDivisionProduction
11/15/2021Haynesville               470,978
11/16/2021Haynesville               207,166
11/17/2021Haynesville               206,027
11/18/2021Haynesville               110,255
11/19/2021Haynesville               222,234
11/20/2021Haynesville               873,405
11/21/2021Haynesville               121,769
11/22/2021Haynesville               651,864
11/23/2021Haynesville           1,326,766
11/24/2021Haynesville               102,000
11/25/2021Haynesville                 78,600
11/26/2021Haynesville               508,940
11/27/2021Haynesville           1,245,385
11/28/2021Haynesville           1,381,440
11/29/2021Haynesville               830,456
11/30/2021Haynesville           1,140,000
12/1/2021Haynesville               570,000
12/2/2021Haynesville           1,140,000
12/3/2021Haynesville           1,995,000
12/4/2021Haynesville               285,000
12/5/2021Haynesville               285,000
12/6/2021Haynesville           1,140,000
12/7/2021Haynesville           1,245,385
12/8/2021Haynesville           1,381,440
12/9/2021Haynesville               830,456
12/10/2021Haynesville               855,000
12/11/2021Haynesville           1,326,766
12/12/2021Haynesville               102,000
12/13/2021Haynesville               508,940
12/14/2021Haynesville           1,245,385
12/15/2021Haynesville           1,381,440

 

2 ACCEPTED SOLUTIONS
CNENFRNL
Community Champion
Community Champion

No worries, pal. After a short, steep learning curve, demystified DAX is just "filter + aggregation", to my understanding.

 

Let's get back on track,

CNENFRNL_0-1638411458803.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

VahidDM
Super User
Super User

Hi Mate,

 

You can also use this measure:

MTD Daily Average = 
CALCULATE( AVERAGE( 'Table'[Production] ), DATESMTD( 'Table'[Date] ) )

 

output:

VahidDM_0-1638447687144.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

4 REPLIES 4
VahidDM
Super User
Super User

Hi Mate,

 

You can also use this measure:

MTD Daily Average = 
CALCULATE( AVERAGE( 'Table'[Production] ), DATESMTD( 'Table'[Date] ) )

 

output:

VahidDM_0-1638447687144.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Awesome! This worked great man, really appreciate the response. You and @CNENFRNL really helped me out a ton. Again, much appreciated!

CNENFRNL
Community Champion
Community Champion

No worries, pal. After a short, steep learning curve, demystified DAX is just "filter + aggregation", to my understanding.

 

Let's get back on track,

CNENFRNL_0-1638411458803.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Man you made that look incredibly easy! I had no idea that there was a DATESMTD formula, and I looked for it, googled it, etc. Really appreciate the help man, my report is working perfectly now. 

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.

Top Solution Authors