cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors