Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Need help to build logic based on status

Hi Team, I have column like Political payment in my table and the values appearing as 4 status( Awaiting Upload, Expired, Not applicable, Valid) and need to combine in 3 values  and change the status as

(Awaiting upload/Expired =No, 

Not applicable= Not applicable

Valid= Yes) 

Need to write this logic on power bi level. 

  • Hi, Anonymous ;

    Or in desktop create a column by dax.

    Column = SWITCH([status],"Valid","Yes","Not applicable","Not applicable","No")

    the final show:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

2 Replies

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous ;

    You could create a conditional column in power query.

    Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcixPzCzJzEtXCC3IyU9MUYrViVZScK0oyCxKhXD88ksUEgsKcjKTE5NyUsFCYYk5mUDJWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [status = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"status", type text}}),
        #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if [status] = "Awaiting Upload" then "No" else if [status] = "Valid" then "Yes" else if [status] = "Not applicable" then "Not applicable" else if [status] = " Expired" then "No" else null)
    in
        #"Added Conditional Column"

    The final show:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous ;

    Or in desktop create a column by dax.

    Column = SWITCH([status],"Valid","Yes","Not applicable","Not applicable","No")

    the final show:


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.