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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
vin26
Resolver I
Resolver I

Calculate Cumulative sum of the measure on Field Parameter

Please help me to calculate Cumulative sum of the measure.

 

I have created a model by using Field Parameter to switch the Dimensions. I wanted to dynamically calculate cumulative sum on the measure and on selected dimension. Please find below data and screenshots.

 

Table 1

IDRegionCompanyBrand
1Region1Company1Brand1
2Region1Company2Brand2
3Region1Company3Brand3
4Region1Company4Brand4
5Region1Company5Brand5
6Region1Company1Brand6
7Region1Company2Brand7
8Region1Company3Brand8
9Region1Company4Brand9
10Region2Company5Brand10
11Region2Company1Brand11
12Region2Company2Brand12
13Region2Company3Brand13
14Region2Company4Brand14
15Region2Company5Brand15
16Region2Company1Brand16
17Region2Company2Brand17
18Region2Company3Brand18
19Region3Company4Brand19
20Region3Company5Brand20
21Region3Company1Brand21
22Region3Company2Brand22
23Region3Company3Brand23
24Region3Company4Brand24
25Region3Company5Brand25
26Region3Company1Brand26

 

Table 2

IDSalesUnit
11651427
21770215
31794351
41964407
51302298
61396382
71861423
81830433
91201269
101749401
111464278
121726313
131903215
141507222
151427218
161599391
171656335
181297214
191983439
201159297
211201289
221624303
231631374
241734438
251444487
261800466

 

Data Model

vin26_0-1724853166911.png

 

vin26_1-1724853227293.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @vin26 

First, create a parameter and put three fields into it

vyohuamsft_0-1724908215653.png

 

Then create a new measure and try the following DAX:

Cumulative Sales Dynamic = 
VAR SelectedDimension = 
    SWITCH(
        TRUE(),
        ISINSCOPE('Table'[Region]), "Region",
        ISINSCOPE('Table'[Company]), "Company",
        ISINSCOPE('Table'[Brand]), "Brand",
        "Other"
    )
RETURN
    SWITCH(
        SelectedDimension,
        "Region",
        CALCULATE(
            SUM('Table (2)'[Sales]),
            FILTER(
                ALLSELECTED('Table'),
                'Table'[Region] <= MAX('Table'[Region])
            )
        ),
        "Company",
        CALCULATE(
            SUM('Table (2)'[Sales]),
            FILTER(
                ALLSELECTED('Table'),
                'Table'[Company] <= MAX('Table'[Company])
            )
        ),
        "Brand",
        CALCULATE(
            SUM('Table (2)'[Sales]),
            FILTER(
                ALLSELECTED('Table'),
                VALUE(MID('Table'[Brand],6,3)) <= VALUE(MID(MAX('Table'[Brand]),6,3))
            )
        ),
        BLANK()
    )

 

Put the parameter field and the measure into table view, the following is previe. When you select other fields in the slicer, the measure dynamically adds them up:

vyohuamsft_1-1724908406758.png

vyohuamsft_2-1724908419376.png

vyohuamsft_3-1724908435104.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

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

1 REPLY 1
Anonymous
Not applicable

Hi, @vin26 

First, create a parameter and put three fields into it

vyohuamsft_0-1724908215653.png

 

Then create a new measure and try the following DAX:

Cumulative Sales Dynamic = 
VAR SelectedDimension = 
    SWITCH(
        TRUE(),
        ISINSCOPE('Table'[Region]), "Region",
        ISINSCOPE('Table'[Company]), "Company",
        ISINSCOPE('Table'[Brand]), "Brand",
        "Other"
    )
RETURN
    SWITCH(
        SelectedDimension,
        "Region",
        CALCULATE(
            SUM('Table (2)'[Sales]),
            FILTER(
                ALLSELECTED('Table'),
                'Table'[Region] <= MAX('Table'[Region])
            )
        ),
        "Company",
        CALCULATE(
            SUM('Table (2)'[Sales]),
            FILTER(
                ALLSELECTED('Table'),
                'Table'[Company] <= MAX('Table'[Company])
            )
        ),
        "Brand",
        CALCULATE(
            SUM('Table (2)'[Sales]),
            FILTER(
                ALLSELECTED('Table'),
                VALUE(MID('Table'[Brand],6,3)) <= VALUE(MID(MAX('Table'[Brand]),6,3))
            )
        ),
        BLANK()
    )

 

Put the parameter field and the measure into table view, the following is previe. When you select other fields in the slicer, the measure dynamically adds them up:

vyohuamsft_1-1724908406758.png

vyohuamsft_2-1724908419376.png

vyohuamsft_3-1724908435104.png

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors