Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
I want to get "Output Column" based on following condition in Power Query (M language):
if column1 value is "Peter" then "Output Column" would be value of (Peter - Fab- Kris) else value from column2
Column1 | Column2 | Output Column |
Peter | 1050 | 1050-95-75 =880 |
Dave | 110 | 110 |
Ali | 56 | 56 |
Fab | 95 | 95 |
Kris | 75 | 75 |
Thanks in advance!
Solved! Go to Solution.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkgtSS1S0lEyNDA1UIrViVZySSxLBfENIVzHnEwgz9QMzHFLTAJyLE3BHO+izGIgzxzIiwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Output", each
if [Column1]="Peter" then [Column2]
-Table.SelectRows(#"Changed Type",each [Column1]="Fab"){0}[Column2]
-Table.SelectRows(#"Changed Type",each [Column1]="Kris"){0}[Column2]
else [Column2])
in
#"Added Custom"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkgtSS1S0lEyNDA1UIrViVZySSxLBfENIVzHnEwgz9QMzHFLTAJyLE3BHO+izGIgzxzIiwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Output", each
if [Column1]="Peter" then [Column2]
-Table.SelectRows(#"Changed Type",each [Column1]="Fab"){0}[Column2]
-Table.SelectRows(#"Changed Type",each [Column1]="Kris"){0}[Column2]
else [Column2])
in
#"Added Custom"
How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done".
User | Count |
---|---|
84 | |
80 | |
72 | |
71 | |
55 |
User | Count |
---|---|
108 | |
106 | |
93 | |
84 | |
66 |