Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX: Ranking a measure based on a Column

Hello All,   I am trying to create ranking of sales by customers and customer groups. Now these customers are been grouped as tier 1 and tier2.   But in visualization I am using only Customer co...
  • v-yalanwu-msft's avatar
    4 years ago

    Hi, Anonymous ;

    Try it.

     

    Total Sales = CALCULATE(SUM('Table'[Sales]),FILTER(ALLSELECTED('Table'),[Customer Group]=MAX('Table'[Customer Group])&&[Customer]=MAX('Table'[Customer])))
    Top 5 Customers = 
        RANKX(
            FILTER( ALL('Table'),[Tier1/2]=MAX('Table'[Tier1/2])),
            CALCULATE(
                [Total Sales])
                
                ,,
                DESC,Dense)

     

    The final show:

    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.