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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors