cancel
Showing results 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

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

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

In doing so, you are also helping me. Thank you!

Proud to be a Super User!

6 REPLIES 6
Community Support

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.

Frequent Visitor

Thank you all for the reply

Here is the sample data.

 Category Units Sales% A 12 60 B 10 50 C 5 50 D 3 75 E 20 34 F 45 50 G 12 90 H 23 89 I 2 100 J 1 0 K 50 20 L 60 10 M 4 54 N 5 90 O 5 40 P 7 40

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.

 Product Units Sales% L 60 10 K 50 20 F 45 50 H 23 89

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

Thank you.

Community Champion

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

In doing so, you are also helping me. Thank you!

Proud to be a Super User!

Community Support

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.

3. Result:

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

Frequent Visitor

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.

Community Champion

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

Announcements

#### 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.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### 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
Top Kudoed Authors