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
AvGonzalez
Frequent Visitor

Calculate Previous MTH

Hello!!

I have a problem when calculating the previous month of total sales.

The formulas I use are the following.

 

Total Units = SUM('BD'[Sales Units])

Previous MTH = CALCULATE([Total Units], DATEADD('BD'[Period],-1,MONTH))

 

and it gives me this problem.

AvGonzalez_0-1674142185178.png

 

Data Base & Power Bi File 

 

I suspect it's a problem with my database, but I can't find if it's a format issue or how the data is contaminated.
can someone help me :c

1 ACCEPTED SOLUTION
marcelsmaglhaes
Super User
Super User

Hey @AvGonzalez ,

 

You can try change your DAX like below:

Previous MTH = CALCULATE([Total Units], PREVIOUSMONTH('FullMarket Venezuela'[Period].[Date]))

marcelsmaglhaes_0-1674145865350.png

*If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Kind Regards,
Marcel Magalhães

 


Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



View solution in original post

4 REPLIES 4
marcelsmaglhaes
Super User
Super User

Hey @AvGonzalez ,

 

If my post helps,pPlease consider Accept it as the solution to help the other members find it more quickly.

Kind regards
Marcel


Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



marcelsmaglhaes
Super User
Super User

Hey @AvGonzalez ,

 

You can try change your DAX like below:

Previous MTH = CALCULATE([Total Units], PREVIOUSMONTH('FullMarket Venezuela'[Period].[Date]))

marcelsmaglhaes_0-1674145865350.png

*If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Kind Regards,
Marcel Magalhães

 


Regards,
Marcel Magalhães
Microsoft Power BI Official Partner
MCT | Certified PL-300 Power BI

If I've helped, don't forget to mark my post as a solution!



Thank you very much, changing my code like that fixed all the problem, thank you 😄

amitchandak
Super User
Super User

@AvGonzalez , You should always use date table joined to date of your table in such cases

 

example

Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month))

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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! Prices go up Feb. 11th.

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.

Jan NL Carousel

Fabric Community Update - January 2025

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