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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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

View solution in original post

3 REPLIES 3
bhanu_gautam
Continued Contributor
Continued Contributor

Thanks @Ritaf1983 this works

@bhanu_gautam 
Glad to help 🙂

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

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.