Forum Discussion

franco94's avatar
franco94
New Member
10 years ago

Count value in a field

Hi!

I am trying to count how many times a specific value appears in a field, and drop that value in a new column, beeing that specific value the value that appears in each row.

 

For example: I have client 1, client 2 and client 3 who have one or more suscriptions each. I want to show in a new column how many suscriptions a client has.

 

WHAT I'VE GOT NOW:

 

Client   Suscription

1                 A

1                 B

1                 C

2                 A

3                 A

3                 B            

 

WHAT I WANT TO HAVE:

 

Client   Suscription  #Suscriptions

1                 A                    3

1                 B                    3

1                 C                    3

2                 A                    1

3                 A                    2

3                 B                    2       

 

I tried to use  

 

CountValues =
CALCULATE ( COUNTROWS ( TableName ); TableName[ColumnName] = " This Value " )

 

but it didn't work. 

 

Thanks!

 

1 Reply

  • Sean's avatar
    Sean
    Community Champion

    franco94 This should work... Let me know.

     

    Subscriptions = CALCULATE(COUNTROWS('Table'), ALLEXCEPT('Table', 'Table'[Client]))