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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
prashant21
New Member

Help with RANkX Function

 I am trying to write the DAX to get a ranking of stores based on sales. The code provided calculates the rank of stores based on their total weekly deals in the 'sales data-set'. But i am geting the same rank (rank 1) for all rows below is the code:-

 

Rank of Stores =
RANKX
(
ALL('sales data-set'), -- Replace 'Stores' with the appropriate table name
[Sum of Weekly Sales],
,DESC
,Dense
)

 

I am trying to get the ranking I can use to do TOP N analysis where N is coming from the parameter.

 

prashant21_0-1689594110217.png

 


 

 

1 ACCEPTED SOLUTION

Hi, Still getting the same issue

 

prashant21_0-1689595258961.png

 

View solution in original post

4 REPLIES 4
prashant21
New Member

Hi@mlsx4, Could you please let me know why it was necessary to add  'sales data-set'[Store] instead of 'sales data-set'?

Oh, I have used ALLSELECTED instead of ALL (It was a try). 
I have seen that it doesn't work. What have you written in the measure [Sum of weekly..]?

It is something silly but using dummy data it works...can you try to do this?

 

Rank of Stores =
RANKX
(
ALL('sales data-set'), -- Replace 'Stores' with the appropriate table name
CALCULATE (SUM ('sales data-set'[column])),
,DESC
,Dense
)

 

 

mlsx4
Memorable Member
Memorable Member

Hi @prashant21 

 

Try with:

 

Rank of Stores =
RANKX
(
ALLSELECTED('sales data-set'[Store]), -- Replace 'Stores' with the appropriate table name
[Sum of Weekly Sales],
,DESC
,Dense
)

Hi, Still getting the same issue

 

prashant21_0-1689595258961.png

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors