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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
queryuser
Helper I
Helper I

If RANK result is not unique then RANK by Earliest Date

Hello,

 

Can I ask for your help? How can I rank request that are similar in rank bu thave different submission times. (Earliest is priority)

 

So there is a ranking in place for requests based on their complexity & impact giving a result in a column "Ranking" (see new column to the right - DAX)

 

So in case the ranking is the same 1:1 2:2 etc. how can I rank & display them based on submission time (see Desired Rank column)

 

Many thanks

 

 

 

queryuser_1-1647867303683.png

 

 

1 ACCEPTED SOLUTION

Hi,

I am not sure if I understood your question correctly, but if you are looking for creating a measure, please try the below. The first suggestion was creating a new column.

 

 

Desired Ranking measure: = 
VAR newtable =
    ADDCOLUMNS (
        ALL ( Report_Complexity ),
        "@newrank",
            VAR timerank =
                CALCULATE (
                    RANKX (
                        ALL ( Report_Complexity ),
                        CALCULATE ( MAX ( Report_Complexity[Submission Time] ) ),
                        ,
                        ASC
                    )
                )
            VAR ranking =
                CALCULATE (
                    IF (
                        SELECTEDVALUE ( Report_Complexity[Complexity Indicator] ) = "Low"
                            && SELECTEDVALUE ( Report_Complexity[Impact indicator] ) = "High",
                        1,
                        IF (
                            SELECTEDVALUE ( Report_Complexity[Complexity Indicator] ) = "High"
                                && SELECTEDVALUE ( Report_Complexity[Impact indicator] ) = "High",
                            2,
                            IF (
                                SELECTEDVALUE ( Report_Complexity[Complexity Indicator] ) = "Low"
                                    && SELECTEDVALUE ( Report_Complexity[Impact indicator] ) = "Low",
                                3,
                                IF (
                                    SELECTEDVALUE ( Report_Complexity[Complexity Indicator] ) = "High"
                                        && SELECTEDVALUE ( Report_Complexity[Impact indicator] ) = "Low",
                                    4
                                )
                            )
                        )
                    )
                )
            RETURN
                timerank + ranking * 10000
    )
RETURN
    IF (
        HASONEVALUE ( Report_Complexity[Request] ),
        RANKX (
            ALL ( Report_Complexity ),
            CALCULATE (
                SUMX (
                    FILTER (
                        newtable,
                        Report_Complexity[Request] = MAX ( Report_Complexity[Request] )
                    ),
                    [@newrank]
                )
            ),
            ,
            ASC
        )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

7 REPLIES 7
johnt75
Super User
Super User

Is it possible to move the whole thing to Power Query? Your Ranking column looks like it could be done in Power Query, you would then be able to sort the table by both Rank and Time and add a index column as your new "Combined Ranking"

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Picture1.png

 

Desired Ranking CC =
VAR newtable =
    ADDCOLUMNS (
        Report_Complexity,
        "@newrank",
            VAR timerank =
                RANKX ( Report_Complexity, Report_Complexity[Submission Time],, ASC )
            VAR ranking =
                IF (
                    Report_Complexity[Complexity Indicator] = "Low"
                        && Report_Complexity[Impact indicator] = "High",
                    1,
                    IF (
                        Report_Complexity[Complexity Indicator] = "High"
                            && Report_Complexity[Impact indicator] = "High",
                        2,
                        IF (
                            Report_Complexity[Complexity Indicator] = "Low"
                                && Report_Complexity[Impact indicator] = "Low",
                            3,
                            IF (
                                Report_Complexity[Complexity Indicator] = "High"
                                    && Report_Complexity[Impact indicator] = "Low",
                                4
                            )
                        )
                    )
                )
            VAR newranknumber = ranking * 100 + timerank
            RETURN
                newranknumber
    )
RETURN
    RANKX (
        newtable,
        MAXX (
            FILTER (
                newtable,
                Report_Complexity[Request] = EARLIER ( Report_Complexity[Request] )
            ),
            [@newrank]
        ),
        ,
        ASC
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


@Jihwan_Kim 

Thank you for the effort! It almost works. The issue here is that the initial RANK looses it's order when submitted date is way later. So any request ranked as 2 in this case shall be #3 instead of 6

queryuser_0-1647871259328.png

 

Hi,

I am not sure if I understood your question correctly, but if you are looking for creating a measure, please try the below. The first suggestion was creating a new column.

 

 

Desired Ranking measure: = 
VAR newtable =
    ADDCOLUMNS (
        ALL ( Report_Complexity ),
        "@newrank",
            VAR timerank =
                CALCULATE (
                    RANKX (
                        ALL ( Report_Complexity ),
                        CALCULATE ( MAX ( Report_Complexity[Submission Time] ) ),
                        ,
                        ASC
                    )
                )
            VAR ranking =
                CALCULATE (
                    IF (
                        SELECTEDVALUE ( Report_Complexity[Complexity Indicator] ) = "Low"
                            && SELECTEDVALUE ( Report_Complexity[Impact indicator] ) = "High",
                        1,
                        IF (
                            SELECTEDVALUE ( Report_Complexity[Complexity Indicator] ) = "High"
                                && SELECTEDVALUE ( Report_Complexity[Impact indicator] ) = "High",
                            2,
                            IF (
                                SELECTEDVALUE ( Report_Complexity[Complexity Indicator] ) = "Low"
                                    && SELECTEDVALUE ( Report_Complexity[Impact indicator] ) = "Low",
                                3,
                                IF (
                                    SELECTEDVALUE ( Report_Complexity[Complexity Indicator] ) = "High"
                                        && SELECTEDVALUE ( Report_Complexity[Impact indicator] ) = "Low",
                                    4
                                )
                            )
                        )
                    )
                )
            RETURN
                timerank + ranking * 10000
    )
RETURN
    IF (
        HASONEVALUE ( Report_Complexity[Request] ),
        RANKX (
            ALL ( Report_Complexity ),
            CALCULATE (
                SUMX (
                    FILTER (
                        newtable,
                        Report_Complexity[Request] = MAX ( Report_Complexity[Request] )
                    ),
                    [@newrank]
                )
            ),
            ,
            ASC
        )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hello,

 

Not very sure if it works but thanks a lot for the effort. Will accept as a solution.

amitchandak
Super User
Super User

@queryuser ,

a new column

Rank = Rankx(Table, Table[Submission Time],,asc,dense)

 

or

Countx(filter(Table, [Submission Time] <= earlier([Submission Time]) ), [Submission Time])

Hi @amitchandak 

 

Thanks for your quick reply.

 

So both options work only to rank the earlies time and does not consider the already existing rank of complexity.

 

So if 2 requests have the same complexity (ex. 1) then rank / prioritze the earlies request 

 

Here the Desired Rank would mean that the earlies request would be ranked first while the later one 2nd

 

How would you do that?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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