cancel
Showing results for 
Search instead for 
Did you mean: 
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
Microsoft

@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
Microsoft

@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
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

Power BI Dev Camp Session 27

Ted's Dev Camp

This session walks through creating a new Azure AD B2C tenant and configuring it with user flows and custom policies.

Health and Life Sciences Power BI User Group

Health and Life Sciences Power BI User Group

Power BI specialists at Microsoft have created a community user group where customers in the provider, payor, pharma, health solutions, and life science industries can collaborate.