Forum Discussion

parry2k's avatar
parry2k
Super User
8 years ago
Solved

count by measure

hi there,

 

I have  a calculated measure to calculate the share % of each category, based on category share there is ranking, if % > 20 then A if % > 10 then B else C

 

I added the measure for ranking as well, so in table category, %  and rank all looks good.

 

I want to count number of categories under each rank. What is the best way to achieve it?

 

thanks,

P

 

 

  • parry2k

     

    Try with this modification:

     

    RANK =
    VAR Share = [% share]
    RETURN
        IF ( Share > 0.10, "A", IF ( Share > 0.05, "B", "C" ) )

    Victor

  • parry2k's avatar
    parry2k
    8 years ago

    VvelardeThanks for getting back. Although I sorted it out but wanted to check how you experts will do. I will test your solution. Cheers!!

8 Replies

  • Just to add more there will be slicer on category so the solution should work if any value is selected in a slicer.

    • Zubair_Muhammad's avatar
      Zubair_Muhammad
      Community Champion

      HI parry2k

       

      Try this approach

       

      Create a calculated table of all available RANKS (a,b,c,d etc)

       

      RANKs = DATATABLE("RANK",STRING,{{"A"},{"B"}})

      Then you can use this MEASURE to count categories against each RANK

       

      Measure =
      COUNTX (
          FILTER (
              ALLSELECTED ( Table1[Category] ),
              [RANK] = SELECTEDVALUE ( RANKs[RANK] )
          ),
          1
      )