Forum Discussion

Chrisjr's avatar
Chrisjr
Helper IV
3 years ago
Solved

replace numbers by a specific text in a column

Hello all,    I have the following column: Colum title  0.5 index1 index2 index3 0.9 index5 index6     I would like to replace the numbers only by a specific text. Ho...
  • BA_Pete's avatar
    3 years ago

    Hi Chrisjr ,

     

    Put this into a new custom column:

    if try Value.Is(Number.From([#"Colum title "]), type number) otherwise false then "IndexType" else [#"Colum title "]

     

    Example output:

     

    Full example query:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtAzVYrViVbKzEtJrTBEMI0QTGMw00DPEiGEpMdMKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Colum title " = _t]),
        addCustom = Table.AddColumn(Source, "Custom", each if try Value.Is(Number.From([#"Colum title "]), type number) otherwise false then "IndexType" else [#"Colum title "])
    in
        addCustom

     

    Pete