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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
MandoPavs008
Frequent Visitor

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
Community Champion
Community Champion

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors