Forum Discussion

Alecsen's avatar
Alecsen
Regular Visitor
5 years ago
Solved

How i can replace a value based on two conditions from another columns

Hello guys,   I need you help in replacing a value in one column based on two criterias :    I have a column "Status Comanda" - Anulata and Total comenzi >0 , i want to replace in the column "Tot...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Alecsen ,

    You can add a custom column in Power Query Editor and delete the original column [Total pickup grup subcomenzi]. You can copy and paste the below codes in your Advanced Editor.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcswrzUksSVTSUbKw0LMwV4rVGaxiBmh8XUMjPSMzsKBTYlViDkjM1EzPyBBVyNxEz9gUVcgAlatroWeMKmJmqmdspBQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Status comanda" = _t, #"Total pickup grup subcomenzi" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Total pickup grup subcomenzi", type number}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "New Column", each if [Status comanda]="Anulata" and [Total pickup grup subcomenzi]>0 then 0 else [Total pickup grup subcomenzi]),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Total pickup grup subcomenzi"}),
        #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"New Column", "Total pickup grup subcomenzi"}})
    in
        #"Renamed Columns"

    Best Regards