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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

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
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.

Top Kudoed Authors