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
Wout
Helper I
Helper I

Sum of whole previous month, not latest date (month and day) -1 month.

 

Hi Forum,

 

I need help.

 

First some information:

 

I have the following measurement:

 

PM1YTDeuro = TOTALMTD(SUM('Sales'[Price]);DATEADD(DATESMTD('sales'[SalesDate]);-1;MONTH))

 

Sales table:

 

ID  | Price  | Salesdate 
1     10       01-06-17
2     20       10-06-17
3     100      20-06-17
4 200 08-07-17
5 300 12-07-17

 

When i run the measurement:

 

It returns: 30

((ID 1 - 10) + (ID 2 - 20))

 

But i want the sum of the whole previous month. Not the latest salesdate (12-07-2017) - 1 month. So between 01-06 - 12-06.

 

Thanks.

 

1 ACCEPTED SOLUTION
fhill
Resident Rockstar
Resident Rockstar

Here you go!

 

Prior_Month = CALCULATE(SUM(Table2[Price]),            // Sum Price
DATESBETWEEN(Table2[Salesdate],                              // Based on Dates Between
Date(YEAR(EDATE(today(),-1)),MONTH(EDATE(today(),-1)),1),   // Date having Year = Today -1 Month / Month = today -1 Month, and Day = 1
EOMONTH(today(),-1)))                                                 // The End Of Month effective today() -1 month

 

 

Capture.PNG




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




View solution in original post

1 REPLY 1
fhill
Resident Rockstar
Resident Rockstar

Here you go!

 

Prior_Month = CALCULATE(SUM(Table2[Price]),            // Sum Price
DATESBETWEEN(Table2[Salesdate],                              // Based on Dates Between
Date(YEAR(EDATE(today(),-1)),MONTH(EDATE(today(),-1)),1),   // Date having Year = Today -1 Month / Month = today -1 Month, and Day = 1
EOMONTH(today(),-1)))                                                 // The End Of Month effective today() -1 month

 

 

Capture.PNG




Did I answer your question, or help you along the way?
Please give Kudos or Mark as a Solution!


https://www.linkedin.com/in/forrest-hill-04480730/

Proud to give back to the community!
Thank You!




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.