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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Sofinobi
Helper IV
Helper IV

Sales MTD last month

Hi all,
please, i would like to compare the sales MTD to the sales same date in last month, and get the result in a card visuel.

for eg, if the current date is 10th january :
Sales MTD = sales from 01 to 10 january (this is ok)
Sales MTD last Month = Sales from 01 to 10 December (this is what i need if possible)

i tested this measure, but it doesn't work exactely on a card vissuel:

Sales MTD LM = CALCULATE([Sales MTD],
                                   DATEADD(CALENDRIER[Date],-1,MONTH))
thank you for your help
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Sofinobi 

May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1704365159998.png

 

 

Measures:

Sales MTD =

VAR selectedDate =

    SELECTEDVALUE ( 'Table'[Date] )

VAR beginningSelectedDate =

    EOMONTH ( SelectedDate, -1 ) + 1

VAR _salesMTD =

    CALCULATE (

        SUM ( 'Sales'[Value] ),

        'Sales'[Date] >= beginningSelectedDate

            && 'Sales'[Date] <= selectedDate

    )

RETURN

    _salesMTD



Sales MTD last Month =

VAR selectedDate =

    SELECTEDVALUE ( 'Table'[Date] )

VAR beginningPeriousMonthDate =

    EOMONTH ( selectedDate, -2 ) + 1

VAR periousSelectedDate =

    EOMONTH ( selectedDate, -2 ) + SELECTEDVALUE ( 'Table'[Date].[Day] )

VAR _salesMTDLastMonth =

    CALCULATE (

        SUM ( 'Sales'[Value] ),

        'Sales'[Date] >= beginningPeriousMonthDate

            && 'Sales'[Date] <= periousSelectedDate

    )

RETURN

    _salesMTDLastMonth

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi, @Sofinobi 

May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1704365159998.png

 

 

Measures:

Sales MTD =

VAR selectedDate =

    SELECTEDVALUE ( 'Table'[Date] )

VAR beginningSelectedDate =

    EOMONTH ( SelectedDate, -1 ) + 1

VAR _salesMTD =

    CALCULATE (

        SUM ( 'Sales'[Value] ),

        'Sales'[Date] >= beginningSelectedDate

            && 'Sales'[Date] <= selectedDate

    )

RETURN

    _salesMTD



Sales MTD last Month =

VAR selectedDate =

    SELECTEDVALUE ( 'Table'[Date] )

VAR beginningPeriousMonthDate =

    EOMONTH ( selectedDate, -2 ) + 1

VAR periousSelectedDate =

    EOMONTH ( selectedDate, -2 ) + SELECTEDVALUE ( 'Table'[Date].[Day] )

VAR _salesMTDLastMonth =

    CALCULATE (

        SUM ( 'Sales'[Value] ),

        'Sales'[Date] >= beginningPeriousMonthDate

            && 'Sales'[Date] <= periousSelectedDate

    )

RETURN

    _salesMTDLastMonth

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Dangar332
Super User
Super User

hi, @Sofinobi 

 

try below

 

sales mtd = totalmtd([salesamount],CALENDRIER[Date])
 
                            and

Sales MTD LM = CALCULATE(
                   [Salesamount],
                    CALENDRIER[Date]>= eomonth(CALENDRIER[Date]-2)+1,
                     CALENDRIER[Date]<=edate( CALENDRIER[Date],-1)   
               )   

 

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

 

MBernalBI
Frequent Visitor

Hello @Sofinobi , 

I have tried with these measures and I have been successful. Try it and let me know if you have been successful

 

Sales MTD = TOTALMTD(SUM(Sales[sales]), CALENDRIER[Date])

Sales MTD LM= CALCULATE([Sales MTD], DATEADD(CALENDRIER[Date],-1, MONTH))

 

If it works for you don't forget to mark your comment as a solution 😄

 

hi @MBernalBI  thanks for your answer, but it doesn't work for me, the Sales MTD LM returns the total sales of last month, its not what i need exactely.
thank you again

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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