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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
DM_95
Helper I
Helper I

Cumulative Sum Measure

Hi,

 

I've made below measure for Cumulative Sales. However I want it slightly different so that when I select for example Months 7, 8 and 9, it only shows cumulative sales as from Month 7 on. So, not showing values € 28.814.316,37 (Month 7), € 30.580.458,70 (Month 8), € 33.891.502,57 (Month 9) but values € 3.315.379,87 (Month 7), € 5.081.522,20 (Month 8 -->  € 3.315.379,87 + € 1.766.142,33) and € 8.392.566,07 (Month 9 --> € 5.081.522,20 + € 3.311.043,87). 

 

Does someone have an idea how to change the measure?

 
Thanks in advance!
 
*Net Sales Cumulative =
CALCULATE (
    [Net Sales],
    FILTER (
        ALL ('Invoice Date'),
        'Invoice Date'[DateFull] <= MAX ('Invoice Date'[DateFull])
            && 'Invoice Date'[YearId] = MAX ('Invoice Date'[YearId])
    )
)
DM_95_0-1667554316295.pngDM_95_2-1667554657625.png
1 ACCEPTED SOLUTION

@DM_95 Should be able to use something along the lines of IF(COUNTROWS(ALLSELECTED('Table')) = 1, <net sales goes here>, <cumulative measure goes here>)


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
DM_95
Helper I
Helper I

@Greg_Deckler Thank you! 

 

I want to use this cumulative measure in another measure as mentioned below (the idea is to switch to cumulative values (VAR _Cumulative) when more than 1 month is selected. If only 1 month is selected, it needs to show the Net Sales(=SUM(Sales[SalesAmount])). However, it does not work properly. Do you have an idea how it might work?

 

*Net Sales VAR =
VAR _Count = COUNTROWS(VALUES('Invoice Date'[MonthInYear]))
VAR _Cumulative = 
CALCULATE (
    [Net Sales],
    FILTER (
        ALLSELECTED ('Invoice Date'),
        'Invoice Date'[DateFull] <= MAX ('Invoice Date'[DateFull])
            && 'Invoice Date'[YearId] = MAX ('Invoice Date'[YearId])
    )
)
RETURN
IF(_Count=1, [Net Sales], _Cumulative)
 

DM_95_0-1667563370459.png

 

@DM_95 Should be able to use something along the lines of IF(COUNTROWS(ALLSELECTED('Table')) = 1, <net sales goes here>, <cumulative measure goes here>)


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

@DM_95 Try using ALLSELECTED vs. ALL


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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