Reply
NickzNickz
Helper IV
Helper IV

How to get cumulative amount and cumulative % for Overall and based on Slicer

Hi ... 
I have created table profit and data as below:

DateCollection ($)Costing ($)Profit ($)
30/1/20234,0009,421(5,421)
24/2/202322,50017,0775,423
10/3/202325,50018,1577,343
11/3/202327,00021,1835,817
7/4/20231,9507,301(5,351)
1/6/20233,0009002,100
31/7/202312,7506,9785,772
31/7/20236,0005,197803
12/8/202332,00021,67810,322
5/9/202311,0004,7826,218
5/9/20234,5503,980570
23/10/20233,0004,556(1,556)
23/10/202331,5007,41124,089
24/10/20239000900
3/1/20245,0003,3391,661
9/1/20245,5003,2882,212
20/1/20244,0002,0271,973
29/1/20244,0002,0271,973
4/2/202417,00012,4444,556
10/2/20248,2507,728522
16/2/202415,00014,061939
20/2/202425,50010,24115,259

 

Based on above data, I need to create a measure for Cumulative Profit ($) and Cumulative Profit (%).
My dashboard setup, I have Year Slicer (dropdown / Multi-select with CTRL), Table, Card and Line Chart.
How can I get the value based on my slicer selection (All or Year Selected).
Regards,

NickzNickz

 

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @NickzNickz ,

You can create the measure as below to get it, please find the details in the attachment.

Cumulative Profit ($) = 
CALCULATE (
    SUM ( 'Table'[Profit ($)] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[Date] <= SELECTEDVALUE ( 'Table'[Date] )
    )
)
Cumulative Profit (%) = 
VAR _all =
    CALCULATE ( SUM ( 'Table'[Profit ($)] ), ALLSELECTED ( 'Table' ) )
RETURN
    DIVIDE ( [Cumulative Profit ($)], _all )

vyiruanmsft_0-1708590064932.png

Best Regards

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

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @NickzNickz ,

You can create the measure as below to get it, please find the details in the attachment.

Cumulative Profit ($) = 
CALCULATE (
    SUM ( 'Table'[Profit ($)] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[Date] <= SELECTEDVALUE ( 'Table'[Date] )
    )
)
Cumulative Profit (%) = 
VAR _all =
    CALCULATE ( SUM ( 'Table'[Profit ($)] ), ALLSELECTED ( 'Table' ) )
RETURN
    DIVIDE ( [Cumulative Profit ($)], _all )

vyiruanmsft_0-1708590064932.png

Best Regards

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

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the  below picture and the attached pbix file.

 

Jihwan_Kim_1-1708490230796.png

 

 

 

Jihwan_Kim_0-1708490110838.png

 

Profit: = 
SUMX(Data, Data[Collection ($)]-Data[Costing ($)])

 

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Cumulative profit %: = 
VAR _allselectedprofit =
    CALCULATE (
        [Profit:],
        WINDOW (
            1,
            ABS,
            -1,
            ABS,
            ALLSELECTED ( 'Calendar'[Date], 'Calendar'[Year]),
            ORDERBY ( 'Calendar'[Date], ASC )
        )
    )
VAR _cumulativeprofit =
    CALCULATE (
        [Profit:],
        WINDOW (
            1,
            ABS,
            0,
            REL,
            ALLSELECTED ( 'Calendar'[Date], 'Calendar'[Year] ),
            ORDERBY ( 'Calendar'[Date], ASC )
        )
    )
RETURN
    IF (
        NOT ISBLANK ( [Profit:] ),
        DIVIDE ( _cumulativeprofit, _allselectedprofit )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hi @Jihwan_Kim ,

 

I am not sure how your semantic model looks like > My date data in the same table.
How can I get value of Cumulative Profit ($).


Btw do i need to create additional column for Year and Month. My date is in Date level and my data in dashboard is by Month and my slicer is in Year.

Example:

NickzNickz_0-1708491562035.png

NickzNickz_1-1708491650076.png

Regards,

NickzNickz

avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)