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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
samihuq
Helper III
Helper III

Count Item of a Table

Hi,

I have a table names "Payment" as follows with four filed. 

I need to generate the fourth coulumn CountItem.

In excel it was farely simple using the countif(), how do we do it here using dax?

 

 

Item Date Amount CountItem

A 01-Jan-2018 10  3

A 02-Jan-2018 10 3

A 03-Jan-2018 10 3

B 01-Jan-2018 10 2

B 02-Jan-2018 10 2

C 01-Jan-2018 10 2

C 02-Jan-2018 10 2

 

 

Thanks,
Sami

2 ACCEPTED SOLUTIONS
Zubair_Muhammad
Community Champion
Community Champion

HI Sami @samihuq

 

CountItem =
VAR myitem = TableName[Item]
RETURN
    COUNTROWS ( FILTER ( TableName, TableName[Item] = myitem ) )

View solution in original post

Anonymous
Not applicable

@samihuq,

You can also use the following DAX.

CountItem = CALCULATE(COUNT(Table[Item]),ALLEXCEPT(Table,Table[Item]))



Regards,

Lydia

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@samihuq,

You can also use the following DAX.

CountItem = CALCULATE(COUNT(Table[Item]),ALLEXCEPT(Table,Table[Item]))



Regards,

Lydia

Thanks @Anonymous your solution also worked like a charm 🙂

Zubair_Muhammad
Community Champion
Community Champion

HI Sami @samihuq

 

CountItem =
VAR myitem = TableName[Item]
RETURN
    COUNTROWS ( FILTER ( TableName, TableName[Item] = myitem ) )

Thanks @Zubair_Muhammad that worked like a charm 🙂

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors