Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Avoid duplicate rank

I need help?

I have written DAX for TOP 5 Case and remaining should be in 'Other' category based on MAX COUNT casetype that is working but problem is in duplicate rank. I have written in TOM Model and RLS has applied:

M2:=

VAR Curr_Case =

    MAX ( FactCase[CaseType] )

VAR Temp_Tab =

    ALL ( FactCase )

VAR Temp_Tab1 =

    SUMMARIZE (

        Temp_Tab,

        FactCase[CaseType],

        "_ACount", COUNTA ( FactCase[CaseType] )

    )

VAR Temp_Tab2 =

    ADDCOLUMNS ( Temp_Tab1, "ARANK", RANKX ( Temp_Tab1, [_ACount] ) )

RETURN

    MAXX ( FILTER ( Temp_Tab2, [CaseType] = Curr_Case ), [ARANK] )

 

 

 

6 Replies

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi Anonymous ,

     

    I tested your provided DAX formula with my sample data, it returned expected RANK value which skips duplicates. You just need an extra measure to class the casetype.

    Category = IF([Rank measure]<=5,SELECTEDVALUE(FactCase[CaseType]),"Other")

     

    Best regards,

    Yuliana Gu

    • Anonymous's avatar
      Anonymous
      Not applicable

       

      Only single value is showing. I have written in TOM Model.
      Not working!

      • v-yulgu-msft's avatar
        v-yulgu-msft
        Microsoft Employee

        Hi Anonymous ,

         

        From this screenshot, were [CaseType] and [M2] both measures? If so, it indeed returns only one single row because there is no row context in such a visual. You have to place some other fields like [CaseType] into visual.

         

        Regards,

        Yuliana Gu

    • Anonymous's avatar
      Anonymous
      Not applicable

      ExpectedOutput I cannot keep in legend(chart) which you have given that is calculated column. In chart I want to use this column in legent section and measure will be count. If you are not clear then I will send sample data file as well.