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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
brycedwhite
Frequent Visitor

Text.StartWith syntax help

I'm trying to replace values in a single text column that begin with a specifc character.  Something like

Table.ReplaceValue(#"Merged Columns","3%",null,Replacer.ReplaceValue,{"Column2"}), but I can't figure out the correct syntax.

 

Thanks in advance for any help.

 

Bryce

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @brycedwhite ,

According to your description, I create a sample.

vkalyjmsft_0-1654770772525.png

In my understanding, if the cell begin with 3% then replace the cell to null. Here's my solution:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWMlZ1AtPOYNLFWBUqqhQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column2", type text}}),
    #"New" = Table.ReplaceValue(#"Changed Type",each [Column2], each if Text.StartsWith(Text.From([Column2]),"3%") then null else [Column2],Replacer.ReplaceValue,{"Column2"})
in
    #"New"

 

Get the correct result.

vkalyjmsft_1-1654770848493.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @brycedwhite ,

According to your description, I create a sample.

vkalyjmsft_0-1654770772525.png

In my understanding, if the cell begin with 3% then replace the cell to null. Here's my solution:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWMlZ1AtPOYNLFWBUqqhQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column2", type text}}),
    #"New" = Table.ReplaceValue(#"Changed Type",each [Column2], each if Text.StartsWith(Text.From([Column2]),"3%") then null else [Column2],Replacer.ReplaceValue,{"Column2"})
in
    #"New"

 

Get the correct result.

vkalyjmsft_1-1654770848493.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

ronrsnfld
Super User
Super User

Might be easier to use the Table.TransformColumns function:

 

= Table.TransformColumns(#"Merged Columns",{"Column2", each if Text.StartsWith(_,"3%")
        then null else _})

 

OR

 

#"Starts with" = Table.TransformColumns(#"Merged Columns",{"Column2", each if Text.StartsWith(_,"3%")
        then Text.ReplaceRange(_,0,2,"") else _})

 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Kudoed Authors