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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Libbyb23
Resolver I
Resolver I

How to Show Bottom 10 Items by Spend

Hi, 

I am needing to show top 10 and bottom 10 items by ytd spend. I am currently using the filters on spend to show top N and bottom N. However, this isnt working correctly because the bottom isnt showing anything over $0 that is still the lowest items bought. The top 10 visual is showing too many items.

Libbyb23_0-1734458079969.png

Libbyb23_1-1734458167643.png

I am also using Analysis Services on a pre-built data model so my changes on the back end are limited. Thanks

 

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Thanks for the reply from Ashish_Mathur  and sevenhills , please allow me to add some more information:

Hi  @Libbyb23 ,

Here are the steps you can follow:

1. Create measure.

Flag =
var _rankasc=
RANKX(
    ALLSELECTED('Table'),CALCULATE(SUM([Rand])),,ASC,Dense)
var _rankdesc=
RANKX(
    ALLSELECTED('Table'),CALCULATE(SUM([Rand])),,DESC,Dense)
RETURN
IF(
    _rankasc<=10||_rankdesc<=10,1,0)

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

vyangliumsft_0-1735201208766.png

3. Result:

vyangliumsft_1-1735201208770.png

 

 

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

View solution in original post

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Thanks for the reply from Ashish_Mathur  and sevenhills , please allow me to add some more information:

Hi  @Libbyb23 ,

Here are the steps you can follow:

1. Create measure.

Flag =
var _rankasc=
RANKX(
    ALLSELECTED('Table'),CALCULATE(SUM([Rand])),,ASC,Dense)
var _rankdesc=
RANKX(
    ALLSELECTED('Table'),CALCULATE(SUM([Rand])),,DESC,Dense)
RETURN
IF(
    _rankasc<=10||_rankdesc<=10,1,0)

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

vyangliumsft_0-1735201208766.png

3. Result:

vyangliumsft_1-1735201208770.png

 

 

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

Ashish_Mathur
Super User
Super User

Hi,

You may use the RANK() function in a measure and then filter that measure with the criteria of < 10.  To receive specific help, share some sample data to work with.


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

 
Use ALLSELECTED or ALL based on your needs! Please share the data that can be readable and can be used by anyone of us to develop DAX!
 
------------------------------------
 
Approach best for your needs
 
Top 10 rank measure  =
CALCULATE (
    [YTD Spend],
    KEEPFILTERS ( TOPN ( 10, ALLSELECTED ( Table1[Base Material Number] ), [YTD Spend], DESC, Dense ) )
)
 
 
Bottom 10 rank measure  =
CALCULATE (
    [YTD Spend],
    KEEPFILTERS ( TOPN ( 10, ALLSELECTED ( Table1[Base Material Number] ), [YTD Spend], ASC, Dense ) )
)
 
------------------------------------
Approach using RANKX
 
Top 10 Items =
CALCULATE ( [YTD Spend],
FILTER ( VALUES ( Table1[Base Material Number]),
IF ( RANKX ( ALL ( Table1), [YTD Spend], , DESC, Dense) <= 10, [YTD Spend], BLANK ())
)
)
 
Bottom 10 Items =
CALCULATE ( [YTD Spend],
FILTER ( VALUES ( Table1[Base Material Number]),
IF ( RANKX ( ALL ( Table1), [YTD Spend], , ASC, Dense) <= 10, [YTD Spend], BLANK ())
)
)
 
 
------------------------------------
 
Hope this helps!

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.