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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
AP23
Advocate I
Advocate I

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 @AP23 
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 @AP23 
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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.