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
Anonymous
Not applicable

Rank with three conditions

Hi All, 

 

I have spent hours on this and yet to find a result that works, I need to be able to dynamically rank based on three conditions:

Conditon 1 = Level

Condition 2 = Semester / Term

Condition 3 = Number of responses (greater than or equal to value on disconnected slicer)

 

The data looks like this:

 

RecordLevelSemester / TermResponsesResult
Record 1UGTerm 146.00
Record 2UGTerm 116.00
Record 3UGTerm 186.00
Record 4UGTerm 1185.75
Record 5UGTerm 1265.75
Record 6UGTerm 1155.60
Record 7PGTerm 1825.56
Record 8PGTerm 145.50
Record 9PGTerm 1245.43
Record 10PGTerm 2495.28
Record 11PGTerm 2515.20
Record 12PGTerm 2775.17
Record 13PGTerm 22345.16
Record 14UGTerm 21765.15
Record 15PGTerm 2195.15
Record 16UGTerm 2655.11
Record 17PGTerm 21675.09
Record 18PGTerm 22785.08
Record 19UGTerm 23785.08
Record 20PGTerm 24955.01

 

Disconnected Responses Slicer:
10
20
50
100

 

my last test looks like this, but I get the error that there were too many arguments for the RANX function. 

I have tried summarize but havent managed to get it working. 

Would really, really appreciate help with this

 

_Test 5 = 

VAR Selected = SELECTEDVALUE(Ranking_Summary_Table_Course[Level])

VAR Term = SELECTEDVALUE(Ranking_Summary_Table_Course[Semester / Term])

RETURN

RANKX (

FILTER (ALL(Ranking_Summary_Table_Course),

'Ranking_Summary_Table_Course'[Responses]>= [Selected_Responses] &&

'Ranking_Summary_Table_Course'[Level] = Selected),

FILTER(Ranking_Summary_Table_Course,

Ranking_Summary_Table_Course[Semester / Term] = Term),


CALCULATE (

[Sum_Result],

ALLEXCEPT('Ranking_Summary_Table_Course','Ranking_Summary_Table_Course'[Record])

),

,

DESC,

DENSE

)
1 ACCEPTED SOLUTION

Hey Keelin,

 

this is the measure:

ms Rank = 
var NoOfResponsesThreshold = SELECTEDVALUE(Slicer[Disconnected Responses Slicer] , 10) 
return
IF(AND(HASONEVALUE('Fact'[Record]) , AND(HASONEVALUE('Fact'[Level]) , HASONEVALUE('Fact'[Semester / Term])))
    ,IF(CALCULATE(SUM('Fact'[Responses])) >= NoOfResponsesThreshold
        ,RANKX(
            FILTER(
                CALCULATETABLE(
                    ADDCOLUMNS(
                        SUMMARIZE(
                            'Fact', 'Fact'[Semester / Term] , 'Fact'[Level] , 'Fact'[Record]
                        )
                        , "NoOfResponses" , CALCULATE(SUM('Fact'[Responses]))
                    )           
                    , ALLEXCEPT('Fact' , 'Fact'[Semester / Term] , 'Fact'[Level])
                )
            , [NoOfResponses] >= NoOfResponsesThreshold
            )
            ,CALCULATE(SUM('Fact'[Result]))
            ,,DESC,Skip
        )
        , BLANK()
    )
)

that allows to create this matrix visual

image.png

Change the parameter from Skip to Dense if you like to see a 2 instead of a 3.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

4 REPLIES 4
TomMartens
Super User
Super User

Hey,

 

this measure:

ms Rank = 
var NoOfResponsesThreshold = SELECTEDVALUE(Slicer[Disconnected Responses Slicer] , 10)
return
IF(AND(HASONEVALUE('Fact'[Record]) , AND(HASONEVALUE('Fact'[Level]) , HASONEVALUE('Fact'[Semester / Term])))
    ,IF(CALCULATE(SUM('Fact'[Responses])) >= NoOfResponsesThreshold

        ,RANKX(
            CALCULATETABLE(
                ADDCOLUMNS(
                    SUMMARIZE(
                        'Fact', 'Fact'[Semester / Term] , 'Fact'[Level] , 'Fact'[Record]
                    )
                    , "NoOfResponses" , CALCULATE(SUM('Fact'[Responses]))
                )            
                ,ALLEXCEPT('Fact' , 'Fact'[Semester / Term] , 'Fact'[Level])
            )
            ,CALCULATE(SUM('Fact'[Responses]))
            ,,DESC,Skip
        )
        , BLANK()
    )
)

allows to create something like this:

image.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Hopefully this provides what you are looking for.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

@TomMartens  Thanks so much for this, its actually the Resutls I want to rank according to the three conditions, I tried to modify your amazing DAX to no avail! 

 

I modified the sum responses to sum results and its bringing back a ranking,  I cant get it to bring back the exact ranking, e.g. I need it to start at 1  for Term 1, UG, Responses > 50. 

Hey Keelin,

 

this is the measure:

ms Rank = 
var NoOfResponsesThreshold = SELECTEDVALUE(Slicer[Disconnected Responses Slicer] , 10) 
return
IF(AND(HASONEVALUE('Fact'[Record]) , AND(HASONEVALUE('Fact'[Level]) , HASONEVALUE('Fact'[Semester / Term])))
    ,IF(CALCULATE(SUM('Fact'[Responses])) >= NoOfResponsesThreshold
        ,RANKX(
            FILTER(
                CALCULATETABLE(
                    ADDCOLUMNS(
                        SUMMARIZE(
                            'Fact', 'Fact'[Semester / Term] , 'Fact'[Level] , 'Fact'[Record]
                        )
                        , "NoOfResponses" , CALCULATE(SUM('Fact'[Responses]))
                    )           
                    , ALLEXCEPT('Fact' , 'Fact'[Semester / Term] , 'Fact'[Level])
                )
            , [NoOfResponses] >= NoOfResponsesThreshold
            )
            ,CALCULATE(SUM('Fact'[Result]))
            ,,DESC,Skip
        )
        , BLANK()
    )
)

that allows to create this matrix visual

image.png

Change the parameter from Skip to Dense if you like to see a 2 instead of a 3.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Anonymous
Not applicable

@TomMartens 

This is absolute magic and so quick! I cant thank you enough and I have learned so much from your code. 

I really appreciate this. 

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.