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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
umaluagr
New Member

Replace letters with null

Hi community

 

Is there a possibility to replace letters in a column with "null"?

 

I have a column that contains rows with letters and rows with numbers. I want to replace only rows with letters with a null value.

e.g.

ABC

123

DEF

234

 

should result in

null

123

null

234

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @umaluagr, add this as a new step.

 

Replace

  • Source with your previous step reference
  • [Column1] with your [ColumnName]
  • "Column1" with your "ColumnName"

dufoq3_0-1714378508112.png

 

= Table.ReplaceValue(Source,
        each try Number.From([Column1]) otherwise false is number,
        each null,
        (x,y,z)=> if y then x else z,
        {"Column1"} )

 

Whole code with sample data:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkxKVorViVYyNDIG045OzmDaxNRMKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,
        each try Number.From([Column1]) otherwise false is number,
        each null,
        (x,y,z)=> if y then x else z,
        {"Column1"} )
in
    #"Replaced Value"

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

1 REPLY 1
dufoq3
Super User
Super User

Hi @umaluagr, add this as a new step.

 

Replace

  • Source with your previous step reference
  • [Column1] with your [ColumnName]
  • "Column1" with your "ColumnName"

dufoq3_0-1714378508112.png

 

= Table.ReplaceValue(Source,
        each try Number.From([Column1]) otherwise false is number,
        each null,
        (x,y,z)=> if y then x else z,
        {"Column1"} )

 

Whole code with sample data:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkxKVorViVYyNDIG045OzmDaxNRMKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,
        each try Number.From([Column1]) otherwise false is number,
        each null,
        (x,y,z)=> if y then x else z,
        {"Column1"} )
in
    #"Replaced Value"

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors