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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Omega
Impactful Individual
Impactful Individual

RANKX Multiple Columns

Hi,

 

I have two fact tables, Sales and Forecast, along with 2 dimension tables, Country and item. 

 

I'm trying to show the top 20 SKUs without highest difference between sales and forecast per country using a measure, can't use column as I'm connected to SSAS. I managed to create the RANKx measure measure but when filtering for TOP 20 at SKU level Power BI keeps processing endlessly. 

 

Problem: How to show the Top 20 SKUs per country using a measure and have Power BI presenet the data in few sec? 

 

 

Ranking = RANKX(ALL('Item'[Item]),[Difference],,DESC)

 

 

 

Thanks!

 

Model.PNG

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Omega 

 

I simulated some data hoping to restore your problem.

Measure:

Difference = ABS(SUM(Sales[Sales])-SUM(Forecast[Forecast]))
Ranking = RANKX(ALL(Country),[Difference],,DESC)

vzhangti_0-1640766212028.png

Place the Ranking measure in filters on this visual, and after setting it as shown, click Apply Filter.

vzhangti_1-1640766351597.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Community Support Team _Charlotte

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

9 REPLIES 9
v-zhangti
Community Support
Community Support

Hi, @Omega 

 

I simulated some data hoping to restore your problem.

Measure:

Difference = ABS(SUM(Sales[Sales])-SUM(Forecast[Forecast]))
Ranking = RANKX(ALL(Country),[Difference],,DESC)

vzhangti_0-1640766212028.png

Place the Ranking measure in filters on this visual, and after setting it as shown, click Apply Filter.

vzhangti_1-1640766351597.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Community Support Team _Charlotte

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

Omega
Impactful Individual
Impactful Individual

The measure will work but it's very slow to generate the results. If I had data for around a million records, it will take min to be executed or it might fail to show the results. 

Ashish_Mathur
Super User
Super User

Hi,

See if this link helps - Vendor Analysis In Inventory Management Dashboards.


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

@Omega and use this measure as a visual level filter where measure is not blank

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Omega maybe create a measure using TOPN instead of using Rank

 

Top N = 
CALCULATE ( [Difference], KEEPFILTERS ( TOPN ( 20, ALL ('Items' ), [Difference], DESC ) ) )

 

and use this measure in the visual.

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Omega how you are trying to get to the Top 20? Are you using the visual level filter on the Rank measure?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Omega
Impactful Individual
Impactful Individual

Exactly. 

smpa01
Super User
Super User

@Omega  is it kindly possible to create a sample pbix and share here?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Omega
Impactful Individual
Impactful Individual

Can't attach files 😞

 

The data is similar to the screenshot with the assumption that we have millions of records. 

 

Thanks!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.