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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
JenniferWallace
Frequent Visitor

How to rank two fields using rankx

I am trying to create a visual like this. 

JenniferWallace_0-1671785570003.png

I am unable to rank transaction count and amount at the same time. When users input how many top N entries they want to see, the count and amount should be ranked dynamically

 

Number of entries =
VAR SelectedTop = SELECTEDVALUE('TopN'[TopN ])
RETURN
SWITCH(TRUE(),
RANKX (
ALLSELECTED( Query[CPO NAME] ),
[Count]
)
<= SelectedTop,[Count]
)
5 REPLIES 5
JenniferWallace
Frequent Visitor

@v-zhangti 

@Mahesh0016 

 

Here is the sample data.  I want to create a topN slicer based on the total of transaction amount and Transaction Count. Based on the number of entries selected it should show me only those number of records.

Example if I Select Number of Entries as 1,

The visual should display C1 with count as 5 and 15100

 

Car IDCar Park IDtransaction amountTotal  of transaction amountTransaction count
C1C1011000151005
C1C1021500
C1C1032500
C1C1042300
C1C1057800
C2C2014537032
C2C202250
C3C2031005503
C3C204450
C3C2052400
C4C11011000110001
C5C234100010001

 

Input :

JenniferWallace_0-1673255934513.png

 

Output :

JenniferWallace_1-1673255956571.png

 

hi @JenniferWallace  can you eaxplain about entries in slicer you use.

 

@Mahesh0016 

 

I am using the Top N Dynamic What if Parameter  approach to rank and filter the entries.

But using this.. I am able to just filter on one attribute ..either transaction count or transaction amount.

 

Number of entries =
VAR SelectedTop = SELECTEDVALUE('TopN'[TopN ])
RETURN
SWITCH(TRUE(),
RANKX (
ALLSELECTEDQuery[CPO NAME] ),
[Count]
)
<= SelectedTop,[Count]
)
v-zhangti
Community Support
Community Support

Hi, @JenniferWallace 

 

Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures. I look forward to your response.

 

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.

Mahesh0016
Super User
Super User

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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