Forum Discussion

sridharbabu's avatar
sridharbabu
Helper I
2 years ago

Rank based on measure

flag =
VAR currOrdern =
    SELECTEDVALUE ( Table1[ordern] )
VAR currlocation =
    SELECTEDVALUE ( Table1[location] )
VAR summary =
    SUMMARIZE ( ALLSELECTED ( Table1 ), [ordern], [location], "_Sales", [Sales] )
VAR filtered =
    TOPN ( 50, summary, [_Sales], DESC )
RETURN
    IF (
        currOrdern
            IN SELECTCOLUMNS ( filtered, "ordern", [ordern] )
                && currlocation IN SELECTCOLUMNS ( filtered, "location", [location] ),
        "Y",
        "N"
    )

This query is working fine . now the additional requirement is to add rank to the table based on[Sales]. It should be o [sales] only if any ordern is duplicate,it  should not consider ordern. purely on [sales] measure only. help me out.

1 Reply

  • v-weiyan1-msft's avatar
    v-weiyan1-msft
    Community Support

    Hi sridharbabu ,

     

    I am not sure how your semantic model looks like, Perhaps you can try code as below to create measure.

    Rank by Sales =
    RANKX ( ALLSELECTED ( Table1 ), [_Sales],, DESC, DENSE )
    

    If your problem is still not resolved, can you share sample data and the results you are hoping for? Show it as a screenshot or excel. Or a sample pbix after removing sensitive data. We can better understand the problem and help you.


    Best Regards,
    Yulia Yan


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