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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Omega
Impactful Individual
Impactful Individual

3 month run rate MTD dates

Hi,

 

I am trying to create a measure that calculates the three months run rate by taking into consideration the same dates in the current month. 

 

In other words, I want to sum the data from the first till the 26th of each of the previous months. 

 

How? 

 

I tried the below code but the measure is considering full month. Please advise. 

 

3M RR = 
CALCULATE (
    [Sales],
    DATESINPERIOD (
        'Date'[Date],
        LASTDATE ( PREVIOUSMONTH ('Date'[Date]) ),
        -3,
        MONTH
    )
)/3

 

1 ACCEPTED SOLUTION
Omega
Impactful Individual
Impactful Individual

Thanks @Ashish_Mathur for your help. 

 

I found an easier way of doing it: 

 

3M RR = 
CALCULATE(sum([sales]), DATESINPERIOD('Date'[Date],LASTDATE(PREVIOUSMONTH('Date'[Date])),-3,MONTH),Day(['Date'[Date]<=DAY(TODAY()-2))/3

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

Need sample data. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

That being said, my Time Intelligence The Hard Way Quick Measure might help:

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Omega
Impactful Individual
Impactful Individual

Thanks for the reply. 

 

PFA sample PBI file along with data. 

 

Basically, there are 3 countries that have data between 1st of April until the 30th of August. 

 

The goal is to create a measure the will sum the sales of the below dates and then divide by 3 (3M RR)

 

  • 1st of May - 26th of May
  • 1st of June - 26th of June
  • 1st of July - 26th of July 

 

Basically, I am considering the 1st date of each month of the previous 3 months and end the month on same day number of today. 

 

 Sample Data: https://1drv.ms/x/s!Akro-bcp8uVLg2xEIUEsf3vO2KCl

Sample PBI: https://1drv.ms/u/s!Akro-bcp8uVLg20CGN9A_YqWu1ee

 

Hi,

 

You may download my PBI file from here.

 

Hope this helps.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Omega
Impactful Individual
Impactful Individual

Thanks @Ashish_Mathur for your help. 

 

I found an easier way of doing it: 

 

3M RR = 
CALCULATE(sum([sales]), DATESINPERIOD('Date'[Date],LASTDATE(PREVIOUSMONTH('Date'[Date])),-3,MONTH),Day(['Date'[Date]<=DAY(TODAY()-2))/3

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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