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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
gabnarmor
Frequent Visitor

RANKX and cumulative sum not working properly.

Hi, 

 

I`ve been trying to do a cumulative sum to make a pareto chart. I`ve tried multiple approaches that at first worked fine, but when combined with some filters I start to get some problems. The formula that has given the best results is 

 

Cumulative = 
CALCULATE([Spend USD], 
           TOPN([Ranking Supplier], 
                ALLSELECTED(f_net_source_saving_invoice[supplier_level_1_parent_name]), 
                [Spend USD], 
                DESC))
 
Where the rank is defined as 

 

Ranking Supplier = 
   RANKX(ALLSELECTED(f_net_source_saving_invoice[supplier_level_1_parent_name]),
    [Spend USD], , DESC)

 

But when using the filters I get the next result

Supplier Spend AmountRanking SupplierCumulative% Accumulated Spend
A31713170.10
B23535520.18
C21437760.25
D2264100050.32
E20062150.07
F181614960.48

I would apreciate any posible solution someone could come up with 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @gabnarmor ,

 

Based on the information you provided, you can follow these steps:

  1. Add new measure.
SORT =

RANKX (

    FILTER ( ALLSELECTED ( 'Table' ), 'Table'[% Accumulated Spend] ),

    CALCULATE ( MAX ( 'Table'[% Accumulated Spend] ) ),

    ,

    ASC

)

 

Cumulative =

CALCULATE (

    SUM ( 'Table'[Spend Amount] ),

    FILTER (

        ALL ( 'Table' ),

        'Table'[% Accumulated Spend] <= SELECTEDVALUE ( 'Table'[% Accumulated Spend] )

    )

)

 

 

Final output:

vyifanwmsft_0-1704956263678.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

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

4 REPLIES 4
Anonymous
Not applicable

Hi @gabnarmor ,

 

Based on the information you provided, you can follow these steps:

  1. Add new measure.
SORT =

RANKX (

    FILTER ( ALLSELECTED ( 'Table' ), 'Table'[% Accumulated Spend] ),

    CALCULATE ( MAX ( 'Table'[% Accumulated Spend] ) ),

    ,

    ASC

)

 

Cumulative =

CALCULATE (

    SUM ( 'Table'[Spend Amount] ),

    FILTER (

        ALL ( 'Table' ),

        'Table'[% Accumulated Spend] <= SELECTEDVALUE ( 'Table'[% Accumulated Spend] )

    )

)

 

 

Final output:

vyifanwmsft_0-1704956263678.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

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

It worked well. Thank you very much.

Ashish_Mathur
Super User
Super User

Hi,

Share some data to work with and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

The data I have is the following

SupplierSpend Amount
A317
B235
C214
D226
E200
F181

 

The desairable result would be 

SupplierSpend Amount% Accumulated SpendRanking SupplierCumulative
A3170.231317
B2350.402552
D2260.573778
C2140.724992
E2000.8751192
F181161373

 

Please take into account that I am working with a lot of filters that users can choose to use or not. So the issue probably can`t be replicated easily even with the data

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors