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

total sales in a month vs total sales in previous year month

Hello, I have been trying to put up total sales in a month and also total sales in the last year of that month together. Ex- If i have some sales sum. And I try to match it with March 2018, it gave me an output. But how do I get the total sales for March 2017 with a drillthrough year wise?

I have tried using DAX with YTM and DATEADD  and also SAMEPERIODLASTYEAR. But I couldn't get the values as they are all blank.

 

Let me know if there is any other way to do it!

Here is a link for my .pbix file on onedrive.

https://ifitech-my.sharepoint.com/:u:/g/personal/moulshree_dhanawade_ifi_tech/ESbVuX9f161BpxelYs1jAI...

2 ACCEPTED SOLUTIONS
v-qiuyu-msft
Community Support
Community Support

Hi @moulshree172

 

Please create a measure below: 

 

Measure =
DIVIDE (
    CALCULATE (
        SUM ( 'Master Sales Report'[Billing Value ( Rs ) GRAND TOTAL] ),
        FILTER (
            ALL ( 'Master Sales Report' ),
            YEAR ( 'Master Sales Report'[Calendar Day.Calendar Day Level 01.Key] )
                = YEAR ( MAX ( 'Master Sales Report'[Calendar Day.Calendar Day Level 01.Key] ) ) - 1
                && MONTH ( 'Master Sales Report'[Calendar Day.Calendar Day Level 01.Key] )
                    = MONTH ( MAX ( 'Fiscal Calendar'[FullDateAlternateKey] ) )
        )
    ),
    100000,
    1
)

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
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

Hi @moulshree172

 

As there are relationships between tables: Master Sales Report and Fiscal Calendar, when you select any value in slicers, YEAR ( MAX ( 'Master Sales Report'[Calendar Day.Calendar Day Level 01.Key] ) ) and MONTH ( MAX ( 'Fiscal Calendar'[FullDateAlternateKey] ) ) is corresponding to the selected slicer values.

 

The logic of my measure is to find the 'Master Sales Report' table rows when year value is equal to YEAR ( MAX ( 'Master Sales Report'[Calendar Day.Calendar Day Level 01.Key] ) )-1 and month value is equal to MONTH ( MAX ( 'Fiscal Calendar'[FullDateAlternateKey] ) ) then calculate total of the 'Master Sales Report'[Billing Value ( Rs ) GRAND TOTAL].

 

For your second question, please create a new measure based on the existing measure [Measure]: 

 

Measure 3 =
VAR t =
SUMMARIZE (
'Master Sales Report',
'Master Sales Report'[Financial Year],
'Fiscal Calendar'[Short Month],
"m", [Measure]
)
RETURN
IF (
ISINSCOPE ( 'Master Sales Report'[Financial Year] ),
[Measure],
SUMX ( t, [m] )
)

 

 

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
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

5 REPLIES 5
v-qiuyu-msft
Community Support
Community Support

Hi @moulshree172

 

Please create a measure below: 

 

Measure =
DIVIDE (
    CALCULATE (
        SUM ( 'Master Sales Report'[Billing Value ( Rs ) GRAND TOTAL] ),
        FILTER (
            ALL ( 'Master Sales Report' ),
            YEAR ( 'Master Sales Report'[Calendar Day.Calendar Day Level 01.Key] )
                = YEAR ( MAX ( 'Master Sales Report'[Calendar Day.Calendar Day Level 01.Key] ) ) - 1
                && MONTH ( 'Master Sales Report'[Calendar Day.Calendar Day Level 01.Key] )
                    = MONTH ( MAX ( 'Fiscal Calendar'[FullDateAlternateKey] ) )
        )
    ),
    100000,
    1
)

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, the total last year value is coming aroung 13.35K. I have attached a screenshot.Totals Sales v/s last year month salesTotals Sales v/s last year month sales

Hi @moulshree172

 

As there are relationships between tables: Master Sales Report and Fiscal Calendar, when you select any value in slicers, YEAR ( MAX ( 'Master Sales Report'[Calendar Day.Calendar Day Level 01.Key] ) ) and MONTH ( MAX ( 'Fiscal Calendar'[FullDateAlternateKey] ) ) is corresponding to the selected slicer values.

 

The logic of my measure is to find the 'Master Sales Report' table rows when year value is equal to YEAR ( MAX ( 'Master Sales Report'[Calendar Day.Calendar Day Level 01.Key] ) )-1 and month value is equal to MONTH ( MAX ( 'Fiscal Calendar'[FullDateAlternateKey] ) ) then calculate total of the 'Master Sales Report'[Billing Value ( Rs ) GRAND TOTAL].

 

For your second question, please create a new measure based on the existing measure [Measure]: 

 

Measure 3 =
VAR t =
SUMMARIZE (
'Master Sales Report',
'Master Sales Report'[Financial Year],
'Fiscal Calendar'[Short Month],
"m", [Measure]
)
RETURN
IF (
ISINSCOPE ( 'Master Sales Report'[Financial Year] ),
[Measure],
SUMX ( t, [m] )
)

 

 

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, 

Thank you for the help. Much appreciated.

@v-qiuyu-msft  

It is working. But can you explain me what exactly this query does?

 

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.