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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
OldMan63
Frequent Visitor

text.contains using beginning or ending spaces in text substring

Unclear how the Text.Contains function treats spaces within the text substring (e.g., "DR" vs. "DR " vs. " DR " vs. " DR"). Will it exactly match the sequence including spaces? If not, how can I do that?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Yes, Text.Contains treats spaces as text. So " DR", "DR", " DR ", and "DR " are not equal. However, each Text.Contains([FieldName], "DR" would = true for each of the above, but " DR " would = true only for " DR ".

 

--Nate

View solution in original post

3 REPLIES 3
dufoq3
Super User
Super User

Hi, @OldMan63Text.Trim could be helful in such situations.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Anonymous
Not applicable

Yes, Text.Contains treats spaces as text. So " DR", "DR", " DR ", and "DR " are not equal. However, each Text.Contains([FieldName], "DR" would = true for each of the above, but " DR " would = true only for " DR ".

 

--Nate

Thanks! That explains why I'm having the problem...not considering the characters before or after the substring. I'll split on all spaces and then do the check using equal operator. Reduces the purmutations to evaluate in a conditional.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors