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

Populating Top N on a Consistent Level Regardless of Slicer

Hello,

 

I am trying to show the Top 5 Level 7 accounts by sales (which is a measure). However, you can slice the page on Level 5, 6 or 7. No matter what the slicer is, I want to show the Top 5 Level 7 accounts of that Level 5, Level 6 or all for that matter. I am running into an issue where more than 5 are showing up. The Account hierarchy and the sales data are in separate tables, connected by a unique Account ID of the lowest level (lower than level 7).

 

Any help would be much appreciated.

 

Best, 

1 ACCEPTED SOLUTION

I needed to add the following filter to not rank blanks or deminimis values.

Rank Level 7 ASC =
VAR _test = AND(NOT(ISBLANK([sales])),[sales]>0)
VAR _result =
IF(
    [sales]=0,BLANK(),
RANKX(
    FILTER(
    ALLSELECTED('_Account Dimension'[Level 7 Desc]),[sales]>0),[sales],,ASC,Dense))
RETURN
IF(_test,_result)

View solution in original post

9 REPLIES 9
AW11
Helper I
Helper I

I was able to show top 5 Level 7 no matter the slicer using this DAX but now need to show bottom 5 as well and simply updating to ASC order is not working.

 

Rank Level 7 DESC =
VAR _test = NOT(ISBLANK([sales]))
VAR _result = RANKX(
    ALLSELECTED('_Account Dimension'[Level 7 Desc]),[sales])
RETURN
IF(_test,_result)

I needed to add the following filter to not rank blanks or deminimis values.

Rank Level 7 ASC =
VAR _test = AND(NOT(ISBLANK([sales])),[sales]>0)
VAR _result =
IF(
    [sales]=0,BLANK(),
RANKX(
    FILTER(
    ALLSELECTED('_Account Dimension'[Level 7 Desc]),[sales]>0),[sales],,ASC,Dense))
RETURN
IF(_test,_result)

I get to here and then if I try to filter on rank for anything less than 6 the table goes blank 

AW11_0-1728149306724.png

 

Hi @AW11 ,

 

On myside, I couldn't reproduce your issue. It works well.

vrzhoumsft_0-1728551394750.png

Please share a sample file with us and show a screenshot to us with the result you want.

You can download the attatchments to compare the data model with yours.

 

Best Regards,
Rico Zhou

 

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

I get to here and then if I try to filter on rank for anything less than 6 the table goes blank 

AW11_0-1728149306724.png

 

Ashish_Mathur
Super User
Super User

Hi,

Share some data to work with and show the expected result.


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

Dept IDLevel 1Level 2Level 3Level 4Level 5Level 6Level 7Level 8
1ABC CompanyWestTOP

XXX

TundraXboxRedPark
2ABC CompanyWestTOPXXXTundraXboxGreenGrass
3ABC CompanyWestTOPXXXCharlieSwitchBlueTree
4ABC CompanyEastLARGEYYYMikePSPYellowBush
5ABC CompanyEastLARGEYYYMikePSPYellowSky
6ABC CompanyEastLARGEYYYMikePSPYellowWater
7ABC CompanyEastLARGEYYYMikePSPPurpleOcean
8ABC CompanyEastLARGEYYYMikePSPTealDirt
9ABC CompanyEastLARGEYYYMikeAndroidBrownRoad
10ABC CompanyEastLARGEYYYMikeAndroidLilacGas
11ABC CompanyEastLARGEYYYMikeAndroidLincolnProtein
12ABC CompanyEastLARGEYYYDurangoAndroidBushLipid

 

Sales Data

Dept IDProducts SoldPriceSales Measure
14426
2428
35315
46424
57535
68324
79436
810550
911333
1015230
1113113
1214114

 

If data is sliced on Level 5 "Mike", I would expect the following level 7s to show:

Yellow, Purple, Teal, Brown, and Lilac

 

If the data is not slice on Account at all, I would expect the following level 7s to show:

Red, Yellow, Teal, Purple, and Brown

 

If the data is slided on Level 6 "Xbox", I would expect the following level 7s to show:

Red and Green.

I cannot understand your question.  Someone who does will help.


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

replying for exposure. Why is there so much spam in this forum?

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.