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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Karim_Hossam
Microsoft Employee
Microsoft Employee

RANKX with multiple conditions

I am trying to use RANkx fonction, to rank the participants of a quiz (hosted in sharepoint list)  in power Bi, based on the below criteria:

 

First in the rank:  The quicker participans to answer the questions (time) + they didn't click on a hint button + they get the correct answer form first trial

secondary in the  rank: The quicker participants to answer the questions (time) + they clicked on a hint button + they get the correct answers form first trial

Last in the rank  : The quicker participants to answer the questions (time) + they got the correct answers form more than one trial.

 

In the table I have the below coloumns:

-Participants name

-Time: (time to answer the questions)

-Click: (if the user has clicked on the hint button (yes or no))

-Correct  answers: (if the user got the right ansers(yes or no)

-trial count :(number of trials to get correct answers)

 

any idea how I can built this fonction?

Thanks

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Karim_Hossam ,

I create a table as you mentioned.

vyilongmsft_0-1716172072160.png

Then I create a calculated column.

Ranking Metric =
VAR TimeScore = [Time]
VAR HintPenalty =
    IF ( [Click] = "yes", 0.5, 0 )
VAR CorrectFirstTry =
    IF (
        'Table'[Correct  answers] = "yes"
            && [trial count] = 1,
        1,
        IF ( [Correct  answers] = "yes", 0.75, 0 )
    )
RETURN
    TimeScore - HintPenalty + CorrectFirstTry

vyilongmsft_1-1716172142464.png

Finally I create a new calculated column and you can get what you want.

Participant Rank = RANKX(ALL('Table'), 'Table'[Ranking Metric], , ASC, Dense)

vyilongmsft_2-1716172394718.png

 

 

 

Best Regards

Yilong Zhou

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Karim_Hossam ,

I create a table as you mentioned.

vyilongmsft_0-1716172072160.png

Then I create a calculated column.

Ranking Metric =
VAR TimeScore = [Time]
VAR HintPenalty =
    IF ( [Click] = "yes", 0.5, 0 )
VAR CorrectFirstTry =
    IF (
        'Table'[Correct  answers] = "yes"
            && [trial count] = 1,
        1,
        IF ( [Correct  answers] = "yes", 0.75, 0 )
    )
RETURN
    TimeScore - HintPenalty + CorrectFirstTry

vyilongmsft_1-1716172142464.png

Finally I create a new calculated column and you can get what you want.

Participant Rank = RANKX(ALL('Table'), 'Table'[Ranking Metric], , ASC, Dense)

vyilongmsft_2-1716172394718.png

 

 

 

Best Regards

Yilong Zhou

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

jupsimarsingh
New Member

Hello ,

You can create a classification column using Switch statement and then use RankX to rank participants based on the classification and their time to answer:
Something like this :
ParticipantClassification =
SWITCH(
TRUE(),
[Correct answers] = "yes" && [Click] = "no" && [trial count] = 1, 1, -- First priority
[Correct answers] = "yes" && [Click] = "yes" && [trial count] = 1, 2, -- Second priority
[Correct answers] = "yes" && [trial count] > 1, 3, -- Last priority
4 -- Default value for participants who don't meet any criteria
)


Create a Ranking and using RankX:
ParticipantRank =
RANKX(
FILTER(
'YourTable',
'YourTable'[ParticipantClassification] = EARLIER('YourTable'[ParticipantClassification])
),
'YourTable'[Time],
,
ASC
)

You can also combine both to get  the final ranking considering both the classification and the time, you can create another calculated column.

Please mark is as solved solution if this resolved your query ! Thanks



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors