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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
Anonymous
Not applicable

Create a Rank

Hi, 

 

I'm trying to create a ranking of the accounts count of this table. 

 

Annotation 2020-08-13 121846.jpg

 

That table is a duplicate of another table that has the real data. I created that table using the command "grouping by" and with the operation count.

 

asad.jpg

 

Basically, I want to know the rank of every ACCOUNT according to the number of appearances (Count) that every account has.

 

I created this formula, but it doesn't work, as it simply shows "1" for all accounts.

 

Rank =
RANKX (
ALL ( 'Tabla Account Count'[Account Name] ),
CALCULATE (
COUNTROWS ( 'Tabla Account Count' ),
ALLEXCEPT ( 'Tabla Account Count', 'Tabla Account Count'[Count] )
),
,
DESC,
DENSE
)
 
jkjk.jpg
 
Thank you very much in advance!
 

 

 

 

 

 

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

You can use this measure

 

Rank Account Name = RANKX( ALL(Table3[Account Name]), CALCULATE(SUM(Table3[Count])),,DESC,Dense)

 

1.jpg

 

Regards,
Harsh Nathani

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

View solution in original post

6 REPLIES 6
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

You can use this measure

 

Rank Account Name = RANKX( ALL(Table3[Account Name]), CALCULATE(SUM(Table3[Count])),,DESC,Dense)

 

1.jpg

 

Regards,
Harsh Nathani

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

AntrikshSharma
Super User
Super User

@Anonymous You are getting 1 because CALCULATE inititates Context Transition and adds the currently iterated  Account Name to the filter context and the formula becomes, 

 

=
CALCULATE (
    COUNTROWS ( 'Tabla Account Count' ),
    'Tabla Account Count'[Account Name] = "Something", -- Coming from context transition
    ALLEXCEPT ( 'Tabla Account Count', 'Tabla Account Count'[Count] )
)

 

 Since ALLEXCEPT being a CALCULATE modifier is evaluated after context transition the COUNTROWS that you get are for whole table and can only be filtered by the Count column. 

 

Try this code instead:

 

Rank =
RANKX (
    ALL ( 'Tabla Account Count'[Account Name] ),
    CALCULATE ( COUNTROWS ( 'Tabla Account Count' ) ),
    ,
    DESC,
    DENSE
)

 

 

Anonymous
Not applicable

Hi. Thanks! But I received the same number 1 for all accounts in the ranking 😞

Can you share the pbix file or the diagram view of your model?
amitchandak
Super User
Super User

@Anonymous , why allexpect

 

Rank =
RANKX (
ALL ( 'Tabla Account Count'[Account Name] ),
CALCULATE (
COUNTROWS ( 'Tabla Account Count' ),
),
,
DESC,
DENSE
)

 

this will rank for COUNTROWS ( 'Tabla Account Count' )

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

The following error appears :

 

Argument '2' in CALCULATE function is required 

 

I don't know exactly what to put since I'm new in DAX 😕

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

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.