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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.