Forum Discussion
JedShields
1 year agoRegular Visitor
CONTAINSTRING not working in FILTER statement?
Hello all, I've got a measure that counts all sites in a table (keyMSSummary) after filtering sites that have a specific Activity Name, and also filter the column Focus Area for anything that cont...
- Anonymous1 year ago
Hi JedShields ,
I create a table as you mentioned.
Then I think you can change your DAX code:
Measure = COUNTX( FILTER( 'keyMSSummary', 'keyMSSummary'[activity_name] = "4G X Symmetry New POP 4G/5G – Cellnex 127 TowerCo" && SEARCH("eMVP", 'keyMSSummary'[focus_area], 1, 0) > 0 ), 'keyMSSummary'[ms5_SiteAccessed_ACT] )Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- 1 year ago
Use FIND instead of CONTAINSSTRING for reliability:
CountSites := COUNTX( FILTER( 'keyMSSummary', 'keyMSSummary'[activity_name] = "4G X Symmetry New POP 4G/5G – Cellnex 127 TowerCo" && FIND("eMVP", 'keyMSSummary'[focus_area], 1, 0) > 0 ), 'keyMSSummary'[ms5_SiteAccessed_ACT] ) If focus_area might be blank, handle it with COALESCE: FIND("eMVP", COALESCE('keyMSSummary'[focus_area], ""), 1, 0) > 0This ensures proper evaluation of the substring check.
rohit1991
Super User
1 year agoUse FIND instead of CONTAINSSTRING for reliability:
CountSites :=
COUNTX(
FILTER(
'keyMSSummary',
'keyMSSummary'[activity_name] = "4G X Symmetry New POP 4G/5G – Cellnex 127 TowerCo"
&& FIND("eMVP", 'keyMSSummary'[focus_area], 1, 0) > 0
),
'keyMSSummary'[ms5_SiteAccessed_ACT]
)
If focus_area might be blank, handle it with COALESCE:
FIND("eMVP", COALESCE('keyMSSummary'[focus_area], ""), 1, 0) > 0
This ensures proper evaluation of the substring check.
- JedShields1 year agoRegular Visitor
Thanks for the advice, I'll make the changes.