Forum Discussion
JollyRoger01
5 years agoHelper III
How to replicate Excel COUNTIF formula?
I am struggling to get my head around the basic layout of DAX, even a simple COUNTIF formula. I have two tables in my data model connected by a field called System. I just wanted to calculate in this...
- 5 years ago
JollyRoger01
I guess you have a one-to-many relationship from this table to table1. Add the following calculated column to the table on the one sideCount System = CALCULATE( COUNTA(Table1[System]), RELATEDTABLE(Table1) )
Fowmy
5 years agoSuper User
JollyRoger01
Yes, since you already have a valid relationship, CALCULATE activates it here.
JollyRoger01
5 years agoHelper III
Okay, I understand that. But how would I do this if I didn't have a relationship?
- Fowmy5 years agoSuper User
JollyRoger01
You can do it this way:Count System = VAR __system = [System] RETURN COUNTROWS ( FILTER ( ALL ( Table1[System] ), Table1[System] = __system ) )- JollyRoger015 years agoHelper III
I can't seem to make that one work. Are you sure that is in the right format?