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
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...


@ 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!:
The Definitive Guide to Power Query (M)

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
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.