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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
krist_pbi
Frequent Visitor

Show sales last month in table visual

Hey this should be really simple

 

I need to show in a table visual the sales by month, but also show the sales for previous month, so in february show Jan sales, in march show feb etc. I tried with "previousmonth" DAX but for some reason didnt work

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @krist_pbi - you can create two measures - one for the current month's sales and another for the previous month's sales.

 

Current Month Sales =
CALCULATE(
SUM(Sales[SalesAmount]),
DATESMTD('Calendar'[Date])
)

 

Instead of PREVIOUSMONTH, you can use DATEADD to shift the date context by one month

Previous Month Sales =
CALCULATE(
SUM(Sales[SalesAmount]),
DATEADD('Calendar'[Date], -1, MONTH)
)

 

Replace 'Calendar'[Date] with your calendar table's date column.The DATEADD function shifts the date context to the previous month.

 

Hope this works in your scenerio





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

Proud to be a Super User!





View solution in original post

3 REPLIES 3
Kedar_Pande
Super User
Super User

@krist_pbi 

Measure for Current Month Sales:

Current Month Sales = SUM(Sales[Sales Amount])

Measure for Previous Month Sales

Previous Month Sales = CALCULATE( SUM(Sales[Sales Amount]), PREVIOUSMONTH(Sales[Date]) )

The PREVIOUSMONTH function works correctly only if you have a properly configured date table, and it is marked as a "Date Table" in your model.

Ensure that your Sales table has a relationship with the Date table on the date column.

 

Place the Month column (from the Date table) on the rows of the table visual.
Add Current Month Sales and Previous Month Sales as values in the visual.

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

rajendraongole1
Super User
Super User

Hi @krist_pbi - you can create two measures - one for the current month's sales and another for the previous month's sales.

 

Current Month Sales =
CALCULATE(
SUM(Sales[SalesAmount]),
DATESMTD('Calendar'[Date])
)

 

Instead of PREVIOUSMONTH, you can use DATEADD to shift the date context by one month

Previous Month Sales =
CALCULATE(
SUM(Sales[SalesAmount]),
DATEADD('Calendar'[Date], -1, MONTH)
)

 

Replace 'Calendar'[Date] with your calendar table's date column.The DATEADD function shifts the date context to the previous month.

 

Hope this works in your scenerio





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

Proud to be a Super User!





awesome, exactly what I needed! this was simple and I cannot believe chatgpt couldnt figure it out, thanks a lot!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.