Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
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
Solved! Go to Solution.
HI Sami @samihuq
CountItem =
VAR myitem = TableName[Item]
RETURN
    COUNTROWS ( FILTER ( TableName, TableName[Item] = myitem ) )
					
				
			
			
				@samihuq,
You can also use the following DAX.
CountItem = CALCULATE(COUNT(Table[Item]),ALLEXCEPT(Table,Table[Item]))
Regards,
Lydia
@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 🙂
HI Sami @samihuq
CountItem =
VAR myitem = TableName[Item]
RETURN
    COUNTROWS ( FILTER ( TableName, TableName[Item] = myitem ) )
					
				
			
			
				Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.