Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
SergiodePao
New Member

DAX formula Using a Measure to search within a text string.

Good day All,

 

Im willing to Search text within a text string. the challenge im facing is that insted of text im willing to use a variable or Measure based on user input, here is my first attempt that works fine but using plain text

 

Column 1 = CONTAINSSTRING(groupofcities[Cities]"KC")
 
CitiesColumn 1
DET, CHI, KC, HOUTRUE
DAL, HOUFALSE
KCTRUE
 
Im willing for instead of using a plain text in the formula to use a variable or Measure. This is what my "NO yet DAXed" Brain is doing so far, and of course is not working.   please help
 
Column 1 = CONTAINSSTRING(groupofcities[Cities][MeasureCitySelected])
 
Thanks so much for your Help
NOTE: Extra point if you can help on what if 2 cities are selected ... if KC and CHI are selected how can I make row 1 to be true and row two & three false base on the multiple selections. 
 
 
 
 

 

3 REPLIES 3
SergiodePao
New Member

Thank You KeyurPatel14 for your willines to help, 

Unfourtunatelly I try did not work ,  when we use a Measure in the condition, like the one you are proposing

Column 1 = CONTAINSSTRING(groupofcities[Cities],[Test]) for some reasson the results is that all rows are TRUE even if they do not contain "KC".

 

I also tried to add an slicer where each city is listed individually , it does work but the problem is that the row that contains "KC" in a group as the row identified as DET, CHI, KC, HOU, still shows FALSE.  in other hand the row that only contain KC that one is TRUE. 

Maybe Im overcomplicating my dashboard but it is required. 

 

Then You can use CONTAINSSTRING() DAX Function to solve your problem.
If you have any queries then please let me know.

KeyurPatel14
Responsive Resident
Responsive Resident

Hi @SergiodePao ,
You can plot a slicer and in that slicer you can add Cities column so the users can select cities from the slicer.
You can also make a measure using SELECTEDVALUE DAX Formula like this:
Test = SELECTEDVALUE(groupofcities[Cities])

this measure will select the values user select using the slicer.
Now you can pass this measure in your measure Column 1.

It would look like this:
Column 1 = CONTAINSSTRING(groupofcities[Cities],[Test])
I hope this will help to solve your problem and if you have any queries then please let me know.
If this helps you then please give it a kudos and mark it as a solution.

Thank you.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.