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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

RANKX always returns 1, ranking by the how often value appears in column

I want to give a rank each [OpenAnswer] in responses by how often each value of responses[OpenAnwer] appears in the column. 

Example:

OpenAnswer
A
B
B
C
C
C

A should get rank 3, B rank 2, and C rank 3

So far I've tried these and all returned 1 for each entry

 

 

MeesteOV = 
VAR SelectedA = SELECTEDVALUE(responses[OpenAnswer]) 
RETURN
RANKX(ALLSELECTED(responses), CALCULATE(COUNTROWS(FILTER(ALLSELECTED(responses), responses[OpenAnswer] = SelectedA))),,desc, Skip)

-------------
MeesteOV = 
RANKX(ALLSELECTED(responses), CALCULATE(COUNTROWS(responses)),,desc, Skip)

---------------
MeesteOV = 
RANKX(ALLSELECTED(responses), CALCULATE(COUNT(responses[OpenAnswer)),,desc, Skip)

 

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , what are the columns you are using in visual?

 

Try like

MeesteOV =
RANKX(ALLSELECTED(responses[OpenAnswer]), CALCULATE(COUNT(responses[OpenAnswer)),,desc, Skip)

 

this will rank of OpenAnswer and will group inside any other non summarized column, say you use OpenAnswer_id then you will get rank =1 and there is one OpenAnswer inside OpenAnswer_id

Anonymous
Not applicable

ALLSELECTED gave problems with a page level filter and I managed to use your code to make this:

MeesteOV = 
IF(
    ISBLANK(SELECTEDVALUE(responses[OpenAnswer])), 
    BLANK(),
    RANKX(ALLSELECTED(responses[OpenAnswer]), CALCULATE(COUNT(responses[OpenAnswer])),,desc, Dense)
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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