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

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
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.