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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
elaadani
Frequent Visitor

Cumulative sum from a measure with ranking

Hello to all !

I have the following problem:

I have a measurement that is calculated from two others. With this measure, I get the ranking according to projects. I would like to have the cumulative value. For that, I am using this formula which is not really useful for me :

 

**bleep** sale = CALCULATE([Sale], TOPN(RANKX(ALL(Proyect[Name]), [Sale],,,Skip),ALL(Proyect[Name]), [Sale]))

 

This is what I have 

elaadani_0-1705607195629.png


and this is what I need

 

elaadani_0-1705607571754.png

 

 




help with this  please.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @elaadani 

May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

vyaningymsft_0-1705638163701.png

Measures:

Cumulative =

VAR CurrentRank = [Ranking]

RETURN

    IF (

        HASONEVALUE ( 'Table'[Name] ),

        SUMX (

            FILTER (

                ALLSELECTED('Table'),

                [Ranking] <= CurrentRank

            ),

            [Sale]

        ),

        SUMX (ALLSELECTED('Table'),[Sale] )

    )

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @elaadani 

May I ask if this is the expected output you are looking for? Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

vyaningymsft_0-1705638163701.png

Measures:

Cumulative =

VAR CurrentRank = [Ranking]

RETURN

    IF (

        HASONEVALUE ( 'Table'[Name] ),

        SUMX (

            FILTER (

                ALLSELECTED('Table'),

                [Ranking] <= CurrentRank

            ),

            [Sale]

        ),

        SUMX (ALLSELECTED('Table'),[Sale] )

    )

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Exactly what I needed. Thank you very much for your help and your time!

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 whether it suits your requirement.

 

Jihwan_Kim_0-1705637122480.png

 

 

 

Sales measure: = 
SUM(Data[Sales])

 

RANK function (DAX) - DAX | Microsoft Learn

 

Rank measure: = 
RANK (
    SKIP,
    ALL ( Data[Name] ),
    ORDERBY ( [Sales measure:], DESC, Data[Name], DESC )
)

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

Cumulate sales measure: = 
CALCULATE (
    [Sales measure:],
    WINDOW ( 1, ABS, 0, REL, ALL ( Data[Name] ), ORDERBY ( [Rank measure:], ASC ) )
)

 

 


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.