'Power B.I - create a measure to add rows with "yes" value
I have a column with "Yes" or "No" values in it and I want to count the number of rows with "yes". I can create a new column and have values =1 or 0 depending on the "Yes" or "No" value in the other column and then create a measure to add those values but this seems like a two step approach where there should be just a one step similar to a SUMIF text = "yes" rule in excel.
Anyone know how to do this?
Thanks
Solution 1:[1]
No need for additional columns, try the following measure:
Count Yes =
CALCULATE(
COUNTROWS([table]),
FILTER(
[table],
[Yes-No-Column] = "Yes"
)
)
Solution 2:[2]
Create a measure:
Count Yes =
CALCULATE (
COUNTROWS ( MyTable ),
MyTable[YesNo] = "Yes"
) + 0
Solution 3:[3]
Let's assume the table is called "ABC", and column where yes/no values is called "yes/no", then this DAX formula will take care of your scenario:
Measure :=
COUNTX ( FILTER ( ABC, ABC[yes/no] = "yes" ), ABC[yes/no] )
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Pratik Bhavsar |
Solution 2 | Olly |
Solution 3 | Luuklag |