Forum Discussion

Srihari_Adabala's avatar
Srihari_Adabala
New Member
3 years ago
Solved

Dynamic Bottom N + Other's category

Hello...

I have created a DAX for Dynamic Top N + Others by using below dax 

Top N Products =
VAR TopNSelected = SELECTEDVALUE('Profitability n'[Profitability n])
VAR TopRevTable  = TOPN(TopNSelected,ALLSELECTED('Pseudo Products'),[Revenue])
VAR TopRevenue = CALCULATE([Revenue],KEEPFILTERS(TopRevTable))
VAR OtherValues  = CALCULATE([Revenue],ALLSELECTED('Pseudo Products')) - CALCULATE([Revenue],TopRevTable)
VAR CurrentBU = SELECTEDVALUE('Pseudo Products'[ProductName])
RETURN
    IF (CurrentBU <> "Others", TopRevenue,OtherValues)
 
Here pseudo refers to seperate table which has products and one extra column "Others" 
I just want create same for Bottom N + others. Kindly help me 

  • You can change the order of the TOPN. By default it uses descending order, so will place the higher values first. If you change it to add ASC after the revenue measure it will show you the worst performing products.

3 Replies

  • You can change the order of the TOPN. By default it uses descending order, so will place the higher values first. If you change it to add ASC after the revenue measure it will show you the worst performing products.

    • Srihari_Adabala's avatar
      Srihari_Adabala
      New Member

      Thanks johnt75 

      It worked for me....
      DAX solution for reference

      Bottom N Products =
      VAR TopNSelected = SELECTEDVALUE('Profitability n'[Profitability n])
      VAR TopRevTable  = TOPN(TopNSelected,ALLSELECTED('Pseudo Products'),[Revenue],1)
      VAR TopRevenue = CALCULATE([Revenue],KEEPFILTERS(TopRevTable))
      VAR OtherValues  = CALCULATE([Revenue],ALLSELECTED('Pseudo Products')) - CALCULATE([Revenue],TopRevTable)
      VAR CurrentBU = SELECTEDVALUE('Pseudo Products'[ProductName])
      RETURN
          IF (CurrentBU <> "Others", TopRevenue,OtherValues)
       



  • v-zhangti's avatar
    v-zhangti
    Icon for Community Support rankCommunity Support

    Hi, Srihari_Adabala 

     

    Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures. I look forward to your response.

     

    Best Regards,

    Community Support Team _Charlotte

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