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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Metstone
Frequent Visitor

Similar to countif in Excel

Hi, I have seen quite a few posts relating to ways of emulating COUNTIF in excel but none of them seem to match what I am after. I have a table in Power BI Desktop I need to add a column that shows an incremental count each time a duplicate value is found in another column. Any help would be appreciated.

 

RefNumber

NewColumn

2254

1

2255

1

2255

2

2255

3

2256

1

2256

2

2257

1

2258

1

2259

1

2259

2

2259

3

2259

4

2260

1

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @Metstone 

First you need to have a column that establishes an order. Go to the query editor and add an index column (Add Column -> Add Index column)

Then in DAX you can create a new calculated column:

NewCol =
CALCULATE (
    COUNT ( Table1[RefNumber] ),
    ALLEXCEPT ( Table1, Table1[RefNumber] ),
    Table1[Index] <= EARLIER ( Table1[Index] )
)

 

View solution in original post

2 REPLIES 2
AlB
Community Champion
Community Champion

Hi @Metstone 

First you need to have a column that establishes an order. Go to the query editor and add an index column (Add Column -> Add Index column)

Then in DAX you can create a new calculated column:

NewCol =
CALCULATE (
    COUNT ( Table1[RefNumber] ),
    ALLEXCEPT ( Table1, Table1[RefNumber] ),
    Table1[Index] <= EARLIER ( Table1[Index] )
)

 

Metstone
Frequent Visitor

Thanks!! That's exactly what I needed.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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