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
MandoPavs008
Helper I
Helper I

Rank by Highest inventory with lowest sales

Hi. Can some one help me with the ranking by highest inventory but lowest sales  to see negatively/profit effecting products. 

Thank you.

1 ACCEPTED SOLUTION

Try :

Temp Rank = 

VAR _Percent = SUM(Table[Sales%])

VAR _RK = RANKX(ALL(Table[Category]), _Percent,, DESC)

RETURN

SUM(Table[Units]) * 10000 + _RK

 

Final Rank = RANKX(ALL(Table[Category]), [Temp Rank], , DESC)

 

Then use the [Final Rank] measure to filter the topn





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

6 REPLIES 6
v-yangliu-msft
Community Support
Community Support

Hi  @MandoPavs008 ,

 

Here is the relevant documentation for sorting by multiple columns, you can view this content:

https://community.powerbi.com/t5/Desktop/Sorting-by-multiple-columns/m-p/536884#M251918

https://community.powerbi.com/t5/Desktop/Sorting-a-table-using-multiple-columns/m-p/447941

https://community.powerbi.com/t5/Desktop/Sorting-by-2-columns/m-p/424449

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

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

Thank you all for the reply

Here is the sample data. 

 

CategoryUnitsSales%
A1260
B1050
C550
D375
E2034
F4550
G1290
H2389
I2100
J10
K5020
L6010
M454
N590
O540
P740

I have three columns with category, units count and sales%, from which i need to rank based on Units count & sales% column, so that i will consider Top N with the highest inventory and less sales%. Solution should be like the below table. 

ProductUnitsSales%
L6010
K5020
F4550
H2389

I have to report Highest inventory category but less sales% to my management.

Thank you.

Try :

Temp Rank = 

VAR _Percent = SUM(Table[Sales%])

VAR _RK = RANKX(ALL(Table[Category]), _Percent,, DESC)

RETURN

SUM(Table[Units]) * 10000 + _RK

 

Final Rank = RANKX(ALL(Table[Category]), [Temp Rank], , DESC)

 

Then use the [Final Rank] measure to filter the topn





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Hi  @MandoPavs008 ,

 

Here are the steps you can follow:

1. Create measure.

Rank =
CALCULATE(RANKX(ALL('Table'),CALCULATE(SUM('Table'[Units])),,DESC))
Flag =
IF(
    [Rank]<=4,1,0)

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_0-1666834072156.png

3. Result:

vyangliumsft_1-1666834072159.png

May I ask how to judge "less sales%", the range of these four Sales% is 10%-89%.

 

Best Regards,

Liu Yang

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

Thank you Liu Yang. I did try rank but my dataset has high inventory in the top 10 with 100% sales so kind of confused, i dont want to see 100% ones. I am looking for sales% less than 100. 

speedramps
Super User
Super User

We want to help you but your description is too vaugue. Please write it again clearly.

Please DON'T copy & paste your DAX that does not work and expect us to fathom what you want to do. That would be crazy. 😀

Please just give a simple non technical functional decscription of what you want, then let us suggest the DAX. Thank you.

Provide example input data as table text (not a screen print) so we can import the data to build a solution for you.
Also provide the example desired output, with a clear description of the process flow.

Remember not to share private data ... we don't want you to get into trouble. 😧

Take care to use the same table and field names in the input, output and description so we can understand your problem and help you.

You will get a quick response if you put time and effort into writing clear problem descriptions.

Vaugue descriptions can waste your time and ourtime.

Look foward to helping you when the above information is forthcoming

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.