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
Paulyeo11
Impactful Individual
Impactful Individual

How to get This Month sales Amount ?

Hi All

 

I have below expression working fine :-

 

This Year = CALCULATE(sum('order'[Price]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
 
This Week = CALCULATE(sum('order'[Price]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
 
Can some one share with me This month and last month expression ?
 
Paul
1 ACCEPTED SOLUTION

Hi @Paulyeo11 ,

Based on the picuture, the desired result of this month should be 40 and result of last month is blank if I got it correctly.

Create measure like this:

_this month = 
CALCULATE (
    SUM ( 'order'[Price] ),
    FILTER (
        ALL ( 'Date' ),
        MONTH ( 'Date'[Date] )
            = MONTH (
                CALCULATE (
                    MAX ( 'SI_PM_'[AR Invoice Date] ),
                    ALLEXCEPT ( SI_PM_, SI_PM_[SOURCE] )
                )
            )
    )
)

_previous month = 
CALCULATE (
    SUM ( 'order'[Price] ),
    FILTER (
        ALL ( 'Date' ),
        MONTH ( 'Date'[Date] )
            = MONTH (
                CALCULATE (
                    MAX ( 'SI_PM_'[AR Invoice Date] ),
                    ALLEXCEPT ( SI_PM_, SI_PM_[SOURCE] )
                )
            ) - 1
    )
)

month value.png

Check the modified file in the below, hopes to help you. If not help, please feel free to let me know.

 

Best Regards,
Yingjie Li

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

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Paulyeo11 , for month, create a rank on the month start date

 

New column in date table

Month Rank = RANKX(all('Date'),'Date'[Month Start date],,ASC,Dense)

 

measure
This Month = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])))
Last Month = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1))

 

for Qtr

Qtr Rank = RANKX(all('Date'),'Date'[Qtr Start date],,ASC,Dense)
This Qtr = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank])))
Last Qtr = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank])-1))

 

refer how to create these start dates in my calender video series or this blog

My Video Series ,

 

1.Creating Financial Calendar - From Any Month
https://community.powerbi.com/t5/Community-Blog/Creating-Financial-Calendar-Decoding-Date-and-Calend...

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
Power BI — Qtr on Qtr with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-qtd-questions-time-intelligence-2-5-d842063da839
Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c324...

Hi Amit

Thank you for your help.

My raw data have current month data :-

Paulyeo11_0-1602664926712.png

 

When i use your expression , no error , but return null value :-

Paulyeo11_1-1602664972201.png

My PBI file :-

https://www.dropbox.com/s/b939tr67qc3g8qu/preWebinarPostCal_PY_DATA%20V003.pbix?dl=0

 

Hope you can let me know where go wrong ?

Paul

Hi @Paulyeo11 ,

Based on the picuture, the desired result of this month should be 40 and result of last month is blank if I got it correctly.

Create measure like this:

_this month = 
CALCULATE (
    SUM ( 'order'[Price] ),
    FILTER (
        ALL ( 'Date' ),
        MONTH ( 'Date'[Date] )
            = MONTH (
                CALCULATE (
                    MAX ( 'SI_PM_'[AR Invoice Date] ),
                    ALLEXCEPT ( SI_PM_, SI_PM_[SOURCE] )
                )
            )
    )
)

_previous month = 
CALCULATE (
    SUM ( 'order'[Price] ),
    FILTER (
        ALL ( 'Date' ),
        MONTH ( 'Date'[Date] )
            = MONTH (
                CALCULATE (
                    MAX ( 'SI_PM_'[AR Invoice Date] ),
                    ALLEXCEPT ( SI_PM_, SI_PM_[SOURCE] )
                )
            ) - 1
    )
)

month value.png

Check the modified file in the below, hopes to help you. If not help, please feel free to let me know.

 

Best Regards,
Yingjie Li

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

Paulyeo11
Impactful Individual
Impactful Individual

Hi Ying

thank you very much for your effect.

paul

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.