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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
InfiniteSheldon
Frequent Visitor

Calculate Previous Month Total When Two Dates Are Equal

I currently have 3 tables - sales, customer, date. For the date table, I am using the [Month End] column (always the last day of the month) on the 'Date Table' to filter the Sales table (see the screenshot below).

 

InfiniteSheldon_2-1689719072134.png


I have written a measure below to calcualte the total mobile sales when the transaction date equals the posting date:


Current Month Mobile Sales = 
Calculate(
Sum(Sales[Total Amount],
Customer[Customer_Type] = "Mobile",
Sales[Transaction Date] = Sales[Posting Date] 

)

How can I get the "previous month Mobile Sales"? I wrote the DAX below:

Calculate(
[Current Month Mobile Sales],

DATEADD('Date Table'[Month End], -1, MONTH)
)

 

However, it only works when there are 31 days in a month. How should I fix it to get the correct "previous month Mobile Sales" when filtering by the [Month End] column?

 

Thanks! 

 

 

1 ACCEPTED SOLUTION

Hi @some_bih, I don't think that's the solution. However, I figured it out myself using 

PREVIOUSMONTH rather than DATEADD('Date Table'[Month End], -1, MONTH). Thanks anyway for your help! 

View solution in original post

4 REPLIES 4
some_bih
Super User
Super User

Hi @InfiniteSheldon did you try DAX function TOTALMTD? Hope this help

https://learn.microsoft.com/en-us/dax/totalmtd-function-dax?WT.mc_id=DP-MVP-4025372 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Hi @some_bih, could you please be more specific? I am not sure how TOTALMTD is going to help calculate previous month total when two dates are the same. 

Hi @InfiniteSheldon 

Apply as measure X=TOTALMTD(

[Current Month Mobile Sales], 'Your Date table date column key')

Check result. Hope this help

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Hi @some_bih, I don't think that's the solution. However, I figured it out myself using 

PREVIOUSMONTH rather than DATEADD('Date Table'[Month End], -1, MONTH). Thanks anyway for your help! 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.