Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi and good day members,
Iam fairly new to power bi and still learning by practicing on my own. Can anybody help me on how i can create "Column D" and "Column E" using the condition in E4 and F4 respectively. I can get the idea in excel but on power query seems a lost for me. Iam expecting result as per image below.
Expected Result
Solved! Go to Solution.
Hello @AMD2183,
You can use below the code of Power Query.
Add a new custom column example "E".
if ([C] = "A" or [C] = "B") and [D] = "PASS" then "PASS"
else if [C] = "C" and [D] = "PASS" then "PASS"
else "FAIL"
And again add new custom column.
if ([E] = "PASS" or [E] = "PASS") and [E] = "PASS" then "PASS"
else "FAIL"
Kind Regards,
Gökberk Uzuntaş
📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!
🔗 Stay Connected:
📘 Medium |
📺 YouTube |
💼 LinkedIn |
📷 Instagram |
🐦 X |
👽 Reddit |
🌐 Website |
🎵 TikTok |
Hi @AMD2183 ,
First of all, it is clear that there is no concept of merging cells in power bi, so there should be a corresponding value for each piece of data. You can refer to the following m code
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kksKMkvcFTSUQLhgMTiYqVYHWRhJyB2S8zMQRN2xlTtBDUETbUTdkOcsBvijN0lzlBDsAgjDIkFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column A" = _t, ColumnB = _t, ColumnC = _t]),
#"Added Custom" = Table.AddColumn(Source, "Column D", each if ([ColumnB] = "A" or [ColumnB] = "B") and [ColumnC] = "Pass" then "Pass" else if [ColumnB] = "C" and [ColumnC] = "Pass" then "Pass" else "Fail"),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Column D.1", each if [ColumnC] = "Pass" then "Pass" else "Fail
"),
#"Grouped Rows" = Table.Group(#"Added Custom1", {"Column A"}, {{"AllPass", each List.AllTrue(List.Transform([Column D], each _ = "Pass")), type logical}}),
#"Merged Tables" = Table.NestedJoin(#"Added Custom1", {"Column A"}, #"Grouped Rows", {"Column A"}, "Grouped Rows", JoinKind.LeftOuter),
#"Expanded Table" = Table.ExpandTableColumn(#"Merged Tables", "Grouped Rows", {"AllPass"}),
#"Added NewColumn" = Table.AddColumn(#"Expanded Table", "Column E", each if [AllPass] then "Pass" else "Fail"),
#"Removed Columns" = Table.RemoveColumns(#"Added NewColumn",{"AllPass"})
in
#"Removed Columns"
Here for Column D you use the logic you provided. For Column D.1 is the simplified logic.
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
In power query there is no merge cell, so after loading data into power query, use fill down to replace any null value with its previous value. Then use add new column and use if as almost the same as excel with the below structure
If ....... then ........else ........
Hello @AMD2183,
You can use below the code of Power Query.
Add a new custom column example "E".
if ([C] = "A" or [C] = "B") and [D] = "PASS" then "PASS"
else if [C] = "C" and [D] = "PASS" then "PASS"
else "FAIL"
And again add new custom column.
if ([E] = "PASS" or [E] = "PASS") and [E] = "PASS" then "PASS"
else "FAIL"
Kind Regards,
Gökberk Uzuntaş
📌 If this post helps, then please consider Accepting it as a solution and giving Kudos — it helps other members find answers faster!
🔗 Stay Connected:
📘 Medium |
📺 YouTube |
💼 LinkedIn |
📷 Instagram |
🐦 X |
👽 Reddit |
🌐 Website |
🎵 TikTok |
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 8 | |
| 8 | |
| 6 | |
| 6 | |
| 5 |