0

In SSAS, I wanted to create a measure that counts the number of rows which the column values contains a specific string. eg. table

|Id|item

|1|greenapple

|2|blueapple2

|3|yellowapple

|4|purplegrape

search for "apple". i want the measure return 3. how should i write the DAX expression?

thanks.

jcy
  • 1
  • 1
  • 8

1 Answers1

0

Step 1 first add a column in your table

AppleFlag := if(SEARCH("apple",Table1[Name],1,0)>0,1,0)

Step 2 then create Measure

Apple Count := SUM(Table1[AppleFlag])

enter image description here

sanjay kumar
  • 316
  • 1
  • 6
  • 1
    Thanks! I do it CALCULATE(COUNTROW(Table), SEARCH("apple",Table[Name],1,0)>0), it works perfectly! – jcy Apr 26 '17 at 07:59