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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
efilipe
Helper IV
Helper IV

If text doesn't contain character

Hi,

 

I know this work for me, but I also want to check if the text doesnt contain a character:

 

if (Text.Contains([DATE], "/") and Text.Length([DATE])=10)

The date field is very messed up with many variations. So I also need to check, like the example above, if there's if no character in the field. Like "Text.DoesnContain". Is there maybe a way to detect if Text.Contain is true or false, maybe?

 

Thank you.

1 ACCEPTED SOLUTION
MarcelBeug
Community Champion
Community Champion

Text.Contains does return true or false already (and you are using it in your formula).

You can reverse the ouput by putting "not " (lower case) in front of it, like in

if (not Text.Contains([DATE], "/") and Text.Length([DATE])=10)

 

Specializing in Power Query Formula Language (M)

View solution in original post

4 REPLIES 4
MarcelBeug
Community Champion
Community Champion

Text.Contains does return true or false already (and you are using it in your formula).

You can reverse the ouput by putting "not " (lower case) in front of it, like in

if (not Text.Contains([DATE], "/") and Text.Length([DATE])=10)

 

Specializing in Power Query Formula Language (M)

@ibarrau I guess Power Query is far less limitated then you might expect... Smiley Wink

Specializing in Power Query Formula Language (M)

Nice Marcel! The other response was not a solution for me because, as I said, the problem was really more complex. Thank you!

ibarrau
Super User
Super User

The thing with power query is that it is limitated. I think you don't need to ask about doesn't contain, just go to false in contains.

E.g:

 

if Text.Contains([DATE], "/") then

if Text.Length([DATE])=10 then "both true"

else "here is different to than 10"

else  "here doesn't contain"

 

Hope this helps.

 

P/D Blank and null can be treated with button transformations.


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.