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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Microsoft Employee
Microsoft 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
Microsoft Employee
Microsoft 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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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