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
dgreen1
Frequent Visitor

Power Query text does NOT end with

I'm trying to say as long as text does not end with " 01" or " 02" then do a transformation, otherwise leave it as is but I get an error that I can't use not with text. Is there another way?

1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

Here is a sample code that will do a transformation (takes the text before the " " delimiter) for all rows that do not end in " 01" or " 02".
Hope this helps point you in the right direction.

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk7MLchJVTAwVIrVQfCMUHjGKDwTFB5QXywA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Extracted Text Before Delimiter" = Table.TransformColumns(#"Changed Type", {{"Column1", each if not Text.EndsWith(_, " 01") and not Text.EndsWith(_, " 02") then Text.BeforeDelimiter(_, " ") else _, type text}})
in
#"Extracted Text Before Delimiter"




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

2 REPLIES 2
ThxAlot
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk7MLchJVTAwVIrVQfCMUHjGKDwTFB5QXywA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"NOT Ends With" = Table.TransformColumns(Source, {"Column1", each if not List.Contains({"01","02"}, _, (x,y) => Text.EndsWith(y,x)) then "do sth with " & _ else _, type text})
in
    #"NOT Ends With"

ThxAlot_0-1703138971510.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



jgeddes
Super User
Super User

Here is a sample code that will do a transformation (takes the text before the " " delimiter) for all rows that do not end in " 01" or " 02".
Hope this helps point you in the right direction.

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk7MLchJVTAwVIrVQfCMUHjGKDwTFB5QXywA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Extracted Text Before Delimiter" = Table.TransformColumns(#"Changed Type", {{"Column1", each if not Text.EndsWith(_, " 01") and not Text.EndsWith(_, " 02") then Text.BeforeDelimiter(_, " ") else _, type text}})
in
#"Extracted Text Before Delimiter"




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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.