Forum Discussion

GIantCow's avatar
GIantCow
New Member
3 years ago
Solved

Calculated Column To Count Occurrences in Column

I feel like this shouldn't be so complicated but I can't seem to come to a working formula.

 

I have some sample data like below. CustomerID and AccountID have a datatype of text. I'd like to create a calculated column that counts the number of times the CustomerID appears in the table.

 

When I try the formula below, it just returns 8 in every row.

 

Occurrence =
     COUNTAX (
          FILTER ( TABLE1, EARLIER ( TABLE1[CustomerID] ) = TABLE1[CustomerID] ),
          TABLE1[CustomerID]
     )

 

CustomerIDAccountIDOccurrence (Expected Output)
111123453
1111122333
1111155113
22249592
222447772
333114581
4444956661

 

I was able to get a measure working when placed in a table visual with the formula: CALCULATE(COUNTROWS(Table1), ALLSELECTED(Table1), VALUES(Table1[CustomerID])) but I need to have a calculated column in the source table as well.

 

Appreciate any help

1 Reply