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

Previous Month Sales with Month Selected in Slicer

Hi All,

 

I got stuck with a DAX measure.

I need to calculate the Current Month's sales and the Previous Month's sales. Both the measures are working perfectly if nothing is selected in the date or month slicer. when I select a month in the slicer then the Previous Month's sales measure is giving a blank.

 

For example, if I select "June" in the slicer table then the Current Month's sales measure should be of June and the Previous Month's sales measure should be of May.

 

My measure are given below:

Current Month Sales =
TOTALMTD (
SUM ( 'Dataset supply chain'[total sale] ),
DATESMTD ( 'Dataset supply chain'[Order date] ))

 

Previous Month Sales =
CALCULATE (
SUM ( 'Dataset supply chain'[total sale] ),
PREVIOUSMONTH ( DATESMTD ( 'Dataset supply chain'[Order date] ) ))

 

I am also attaching screenshots of the results.

 

Looking forward toCurrentMonth.jpgCurrentMonth-Selected.jpg a solution.

 

 

Thanks,

Sid

6 REPLIES 6
Sid8686
Frequent Visitor

Multiple columns cannot be converted to a scalar value

 

 

Sid8686
Frequent Visitor

Thanks, it works.
One more question regarding the same visual. how i can calculate the TOP 5 products (by sales) of the Current Month and the Top 5 products (by sales) of the Previous Month? I am trying the above measures with the TOPN function but it is giving me error.

Please do let me know if anyone here helps me how to solve this

Hello , any solution for this query?

 

What is the error message ?

johnt75
Super User
Super User

Firstly, create a proper date table and link it to your fact table. Then you can create measures like 

Current Month Sales =
TOTALMTD ( SUM ( 'Dataset supply chain'[total sale] ), 'Date'[Date] )

Previous Month Sales =
CALCULATE (
    SUM ( 'Dataset supply chain'[total sale] ),
    PREVIOUSMONTH ( 'Date'[Date] )
)

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.

Top Solution Authors