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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
EpicTriffid
Helper IV
Helper IV

Top 15 Values

Hi all,

 

I'm really beginning to lose my rag with RANKX and TOPN, or at least in trying to work out what I'm doing.

 

I want to be able to isolate the top 15 rows in my table, including the top 15 of any filtered results:

 

EpicTriffid_0-1729162735222.png

 

So the user can filter on Provider or Course Name on the page, and I only ever want it to show the top 15 of the returned rows. using a TOPN filter on Course or Provider Name does nothing, so I've tried to use RANKX, RANK, and TOPN, with the only tangible results that aren't just infinite 1's coming from RANKX with the following code:

 

Ranking = RANKX(ALLSELECTED('54'[Course name],'54'[2023]), CALCULATE(SUM('54'[2023])))

 

This gives me the following result (far left column): 

EpicTriffid_1-1729162952585.png

Absolutely no idea what's going on here!

 

Can anyone shed some light on this, on what I might be missing in my understanding? Cheers!

 

8 REPLIES 8
consvax
New Member

Not going to lie. I have no advice as I have been in the same boat for 40 hours now.  I do not undstand why we can't use SQL to create some views in Power BI because DAX gets real messy.

 

I am trying to get the Top 5 ranked builds off of my Top 15 categories ranked by sales$'s and no matter what I do the data change when I change the format of the visual.  Meaning including a measure or not.  

EXAMPLE:

consvax_0-1744142981714.png

Build Rank on Top 15 =
RANKX(
    FILTER(ALL(Gender_Category[Gender Category]), [CategoryRankLastWeek] <= 15 ),
    [Build],
    ,
    DESC,
    Dense
) consvax_1-1744143212857.png

 

It's NOT USING MY TOP 15!  And why is "4" repeated so much when those numbers it is based off not even close to the same value???

Anonymous
Not applicable

Hi, @EpicTriffid 

 

Rank = RANKX(ALL('Table'),CALCULATE(SUM('Table'[2023]),ALLSELECTED('Table'[Provider name 2023],'Table'[Course name])),,DESC)

vzhangtinmsft_0-1729243716486.png

Is this the result you were hoping for? If not, can you provide example data and a description of your desired output?

 

Best Regards,

Community Support Team _Charlotte

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

Bibiano_Geraldo
Super User
Super User

1- Create a Measure to sum your 2023 column

SumOf2023Column = 
SUM(
    '54'[2023]
)

 

2- Create Other Measure to rank your table

Ranking= 
RANKX(
    ALL('54'[Course name], 
    [SumOf2023Column] , , 
    DESC, 
    Skip
)
shafiz_p
Super User
Super User

Hi @EpicTriffid  This is my data. I want to find top 15 CS names by # of orders. To find rank try below code:

 

Rank = 

RANKX(
    ALLSELECTED('CS Data'),
    [# of Order],
    ,
    DESC,
    DENSE
)

 

shafiz_p_0-1729163883692.png


To filter out only top 15, try below code:

 

Top 15 = 
IF([Rank] <= 15, 1, BLANK())

 

Now use this measure in filter this visual option. See image below:

shafiz_p_1-1729164087082.png

 

Here is the top 15. Now you can filter using any dimension.

Hope this helps!!

If this solved you problem, please accept it as a solution!!

 

Best Regards,
Shahariar Hafiz

Sorry. Thankyou for the suggestion but the result in the same

uzuntasgokberk
Super User
Super User

Hello @EpicTriffid ,

Can you change the dax code:

test =
RANKX(ALLSELECTED(RANKTEST[Course name]),CALCULATE(SUM(RANKTEST[2023])),,DESC,Dense)

Kind Regards,
Gökberk Uzuntaş

📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

🔗 Stay Connected:
📘 Medium |
📺 YouTube |
💼 LinkedIn |
📷 Instagram |
🐦 X |
👽 Reddit |
🌐 Website |
🎵 TikTok |

Thank you for the suggestion, but the results are the same as the second screenshot I posted above. Ranking just doesn't seem to want to work on this data. To be clear, there are no additional filters on the table beyond the columns that you can see. The columns are Provider, Course Name, 2019, 2020, 2021, 2022, 2023.

Hello @EpicTriffid,

 

Sorry I forgot to add another your text column. Could you please use below the code:

test =
RANKX(ALLSELECTED(RANKTEST[Coursename],RANKTEST[ProviderName]),CALCULATE(SUM(RANKTEST[2023])),,DESC,Dense)

Kind Regards,
Gökberk Uzuntaş

📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!

🔗 Stay Connected:
📘 Medium |
📺 YouTube |
💼 LinkedIn |
📷 Instagram |
🐦 X |
👽 Reddit |
🌐 Website |
🎵 TikTok |



Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.