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
jpriemer
Advocate I
Advocate I

Total sales for previous calendar month

Hello, I am trying to calculate the total sales of the previous month. For example, today is Feb 8 and I want to see the total sales from all of January. Below is the formula I am using but I am getting the previous month from today, so Jan 8 - Feb 8. What am I doing wrong? 

 

Value MTD =
TOTALMTD(SUM(Opportunity[Actual Value]),PREVIOUSMONTH('Actual Close Date Parts'[Date].[Date]))
1 ACCEPTED SOLUTION
jpriemer
Advocate I
Advocate I

I was able to get the calculation to work by using the following DAX:

last_month_sales = var current_month= MONTH(TODAY()) return CALCULATE(SUM(Opportunity[Actual Value]),FILTER('Date Table',MONTH('Date Table'[Date])=current_month -1))

View solution in original post

3 REPLIES 3
jpriemer
Advocate I
Advocate I

I was able to get the calculation to work by using the following DAX:

last_month_sales = var current_month= MONTH(TODAY()) return CALCULATE(SUM(Opportunity[Actual Value]),FILTER('Date Table',MONTH('Date Table'[Date])=current_month -1))
amitchandak
Super User
Super User

@jpriemer , Please use date table in this case

 

Value MTD =
calculate(SUM(Opportunity[Actual Value]),PREVIOUSMONTH('DAte'[Date]))

 

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 so much for the quick response. Unfortunately, I am still getting values Jan 8 - Feb 8?

Here is my edited formula: 

Value MTD =
CALCULATE(SUM(Opportunity[Actual Value]),PREVIOUSMONTH('Actual Close Date Parts'[Date].[Date]))

 

jpriemer_0-1612798244908.png

 

 

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.