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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.