Forum Discussion

markabdey's avatar
markabdey
Frequent Visitor
5 years ago
Solved

Where Clause for Custom Column

Hi In Power Query I'm trying to create a Custom Column that is populated by a value from another column in the same table where a flag is set to 'Y'. I can't seem to get the right syntax in M to get...
  • AlB's avatar
    5 years ago

    Hi markabdey 

    Place the following M code in a blank query to see the steps.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjC3MjY4tEBJR8lPKVYHzDcxBfMjIXwLKwO4fCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t, Flag = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", type time}, {"Flag", type text}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each #"Changed Type"{[Flag="Y"]}[Time], type time)
    in
        #"Added Custom"

     

    Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.