Search code examples
powerbidaxdata-analysispowerbi-desktopmeasure

dax contains() not showing Tru but should be


I'm stumped here. I have this measure.

Contains = IF(CONTAINS(Flags, Flags[FlagsConcat], SELECTEDVALUE(SlicerFlags[FlagNames])),1,-1)

The concatenated column looks something like this

Flags

id      Bco Nat Gur Ga  An  Sim Oak Ort FlagsConcat

1826    0   0   0   0   0   0   1   1   Oakpoint,Orthoselect
1784    0   0   0   0   0   0   1   1   Oakpoint,Orthoselect
1503    0   0   0   1   0   0   0   0   Guardian
1502    0   0   0   1   0   0   0   0   Guardian
1500    0   0   0   1   0   0   0   0   Guardian
1499    0   0   0   1   0   0   0   0   Guardian
1326    0   0   0   1   0   0   0   0   Guardian
925 0   0   0   1   0   0   0   0   0   Guardian

and here is the values I am grabbing from the selectedvalue()

FlagNames

Benco
National
Guardian-Simply Clear
Guardian
Angel Align
Simply Clear
Oakpoint
Orthoselect
None

If I select Guardian in the slicerFlags table then I get a return value of 1 but if I select either Oakpoint or Orthoselect then I get a -1 even those there are 2 rows in the table that have either word in the FlagsConcat column. I tried putting spaces before and after the comma but that made no difference. Anyone know why the contains() function isn't showing true when looking for Oakpoint or Orthoselect? Thanks in advance.


Solution

  • @Jeroen's code is correct...

    Contains = COUNTROWS(FILTER(Flags, CONTAINSSTRING(Flags[FlagsConcat], SELECTEDVALUE(SlicerFlags[FlagNames]))))+0 
    

    enter image description here

    enter image description here

    enter image description here

    enter image description here enter image description here

    enter image description here enter image description here