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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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 ) )

Regards
Zubair

Please try my custom visuals

View solution in original post

v-yuezhe-msft
Employee
Employee

@samihuq,

You can also use the following DAX.

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



Regards,

Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yuezhe-msft
Employee
Employee

@samihuq,

You can also use the following DAX.

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



Regards,

Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @v-yuezhe-msft 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 ) )

Regards
Zubair

Please try my custom visuals

Thanks @Zubair_Muhammad that worked like a charm 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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