Hey, few ways you could approach this:
- the 'simplest' is probably to create a calculated column in your table that uses the SEARCH() function to check for affirmed in each column and add 1s where it is the case to give you a count e.g.:
Code:
=
IFERROR (
IF ( ISNUMBER ( SEARCH ( "Affirmed", [Column A] ) ), 1, 0 ),
0
)
+ IFERROR (
IF ( ISNUMBER ( SEARCH ( "Affirmed", [Column B] ) ), 1, 0 ),
0
)
+ IFERROR (
IF ( ISNUMBER ( SEARCH ( "Affirmed", [Column C] ) ), 1, 0 ),
0
)
This isn't pretty and perhaps there is a more elegant way but it works! The way SEARCH() works in DAX is stupid as if it doesn't find the string it produces an error regardless of the ISNUMBER() so has to be wrapped in an IFERROR().
- the 'better' way is to do it in a measure. This won't be particularly clean as PowerPivot is 'column' based so you will need to do the calc for each column. A measure would look like this:
Code:
=
CALCULATE (
COUNTROWS ( Table1 ),
Table1[Column A]
= "Affirmed"
)
+ CALCULATE (
COUNTROWS ( Table1 ),
Table1[Column B]
= "Affirmed"
)
+ CALCULATE (
COUNTROWS ( Table1 ),
Table1[Column C]
= "Affirmed"
)
Again this isn't going to win prizes for elegance but gets it done. Note this counts how many times the word appears not how many rows it appears in!