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
alexei7
Continued Contributor
Continued Contributor

RANKX DAX column help

Hi,

I'm trying to create a column that will rank Invoices across Suppliers.

This needs to be a column so that I can then use this Rank column to create a cumulative total and then (hopefully a measure to flag/show the Suppliers which make up the top 80% of our spend.

Having googled and browsed this forum i'm struggling to come up with something that works for me.

 

My data looks like this:

 

SupplierCodeInvoiceNumberInvoice Amount
S1000000:892347892£100
S1000001Jeff:2343234£101
S1000002Jeff:239048912£10
S1000002Susan:93240923£5
S1000002:9239239£50
S1000003:2930499023£25
S1000001Greg:8293489£5

 

I want to create either of the two results:

 

1. A table with the extra rank column, where rank is appled based on the total across the SupplierCode

SupplierCodeInvoiceNumberInvoice AmountRank
S1000000:892347892£1002
S1000001Jeff:2343234£1011
S1000002Jeff:239048912£103
S1000002Susan:93240923£53
S1000002:9239239£503
S1000003:2930499023£254
S1000001Greg:8293489£51

 

2. If the above is not possible, a derived table such as the below:

SupplierCodeInvoice AmountRank
S1000000£1002
S1000001£1011
S1000002£103
S1000003£54

 

Much appreciated,

Alex

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@alexei7

 

As a calc column,,,try

 

Calc Column =
RANKX (
    Table1,
    CALCULATE (
        SUM ( [Invoice Amount] ),
        ALLEXCEPT ( Table1, Table1[SupplierCode] )
    ),
    ,
    DESC,
    DENSE
)

View solution in original post

5 REPLIES 5
v-frfei-msft
Community Support
Community Support

Hi @alexei7,

 

To create two measures as below.

 

total = CALCULATE(SUM(Table1[Invoice Amount]),ALLEXCEPT(Table1,Table1[SupplierCode]))
rankx = RANKX(ALLSELECTED(Table1[SupplierCode]),[total],,DESC,Skip)

Capture.PNG

 

Also to create a calculated columm worked well.

 

rankxcc = RANKX(ALLSELECTED(Table1[SupplierCode]),[total],,DESC,Skip)

 

For more details, please check the pbix as attached.

 

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Zubair_Muhammad
Community Champion
Community Champion

@alexei7

 

As a calc column,,,try

 

Calc Column =
RANKX (
    Table1,
    CALCULATE (
        SUM ( [Invoice Amount] ),
        ALLEXCEPT ( Table1, Table1[SupplierCode] )
    ),
    ,
    DESC,
    DENSE
)

Thanks for your help @Zubair_Muhammad

 

Unfortunately this isn't working for me.

 

I probably should have mentioned that my dataset includes about 30 other columns (which are not required for this calculation). I guess that might be important when using ALLEXCEPT.

 

 

See below for dummy data with the formula you helped with:

 

Supplier Code

Invoice Amount

* Rank Column

S687255

 £             23,029,923

4

S241863

 £               1,100,000

52

S712616

 £               2,700,210

75

S331533

 £               3,700,210

126

S943796

 £                   800,000

126

S14822

 £                   200,000

132

S229347

 £                   400,000

163

S714313

 £               6,333,333

168

S18322

 £                   100,000

214

S69059

 £                     52,000

215

S628244

 £                   120,000

230

 

Any further ideas?

Thanks again

Alex

@alexei7

 

Any number of columns shouldn't make a difference I believe.

 

Could you share your file?

 

Is the result below from a Table Visual in Report....Perhaps it is summing the RANKs...may be you need to mark the RANK column as "Dont summarize"

Could you share screen shot from dataview

 

dataview.png

Thanks so much @Zubair_Muhammad - the issue was summing the RANKs, also I think the reason why my own attempts were failing.

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