Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

New column to count number of instances in same table

Hi,

 

Hope someone can help with the following please:

 

I have the below TableA:

Person_IDSessionCategory

11

Short Day
22Full Day
11Full Day
33AM

 

I want to add a column to this table which shows the number of rows which contain the same Person_ID, such as the below:

Person_IDSessionCategoryRepeatedID

11

Short Day2
22Full Day1
11Full Day2
33AM1

 

I don't want to remove any rows at this stage, as I need to use the above to create two other tables filtered on a) Person_IDs showing just once, and b) Person_IDs that show 2 or more times.

 

Please can you advise how I can achieve this?

I have tried the following but I am receiving an error stating "The function COUNTX cannot work with values of type Boolean". (I have the column set to Data Type "Whole number".)

 

RepeatID =
var Test =
        TableA[Person_ID]
RETURN
        COUNTX(TableA, TableA[Person_ID] = Test)

Many thanks. 

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @Anonymous 
Please add a calculated column with the dax formula = 

repats = CALCULATE(count('Table'[Person_ID]),ALLEXCEPT('Table','Table'[Person_ID]))
Ritaf1983_0-1701706288493.png

the pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

3 REPLIES 3
bhanu_gautam
Super User
Super User

Thanks @Ritaf1983 this works




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@bhanu_gautam 
Glad to help 🙂

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Ritaf1983
Super User
Super User

Hi @Anonymous 
Please add a calculated column with the dax formula = 

repats = CALCULATE(count('Table'[Person_ID]),ALLEXCEPT('Table','Table'[Person_ID]))
Ritaf1983_0-1701706288493.png

the pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.