Forum Discussion

WLFRD's avatar
WLFRD
Helper III
4 years ago

Count per group

Hello,

 

I think the solution for my question is simple but for some reason I cannot find the answer to my question.

 

So, I have this table:

 

Unit
B100
B200
B100 
C100
C100
C100
C100
B100 
B100 
B100 
B100 
B100 
A400
A500
A500
A400
A400
A400
B200
B200

 

And I would like to count the units and sum it per unit. Result will look like this:

 

UnitSUM_OF_Unit
A4004
A5002
B1007
B2003
C1004

 

Can someone help me out?

 

Thanks in advance. 

3 Replies

    • WLFRD's avatar
      WLFRD
      Helper III

      When I use this expression, it counts the total amount of units. I would like to have a total count per unit. In Power BI you can click on 'count' at values ​​and then the total will be shown. I just need a column for a calculation and then I need a column with the totals per unit.
      Does this count have to be filtered?

  • v-xiaotang's avatar
    v-xiaotang
    Community Support

    Hi WLFRD 

    You can try this,

    measure code:

    SUM_OF_Unit_measure = 
    CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Unit] ) )

    calculated column code:

    SumOfCount_column = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Unit]))

    Best Regards,

    Community Support Team _Tang

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