Forum Discussion
jamiers
3 years agoHelper I
Add New Columns into Power Query instead of Power BI Desktop
I have two new columns that I am putting into each Power Query table on the Power BI Desktop side and I would rather do this in Power Query. I was wondering if there would be a way to accomplish thi...
m_dekorte
3 years agoResident Rockstar
Hi jamiers
I'd like to add something to the info already provided by tackytechtom because I noticed that you've got a duplicate expression inside your IF statement. This is something that can be avoided by storing the result of that expression in another variable by nesting a let-expression for example, that could look like this:
AddComply = Table.AddColumn( PrevStepNameHere, "Comply-SA", each
let
a = List.Contains({"", null}, [#"GAP-IDC/DMH.GAP IDC/ DMH/"]),
b = ( [DCSOVRW.DCS Ovr] = "√"
and [DCSCNPBAS.CNP Bas] = "√"
and [DCSDEPFUNDTM.Dep Fnd Away] = "√"
and [DCSMISCDOVR.Mis Cd Ovr] = "√"
and [DMHINTR.DMH Intro] = "√"
and [DMHFUND1.DMH Fnd 1] = "√"
and [DMHFUND2.DMH Fnd 2] = "√"
and [DCSEIW.EIW] = "√"
)
in
if a = true
then (if b = true then "ALERT" else "Training Not Complete")
else (if b = true then "Yes" else "No")
)
You'll need to update the initial table reference with the previous step name in your query where it says PrevStepNameHere. Also not knowing your data I've tested [GAP-IDC/DMH.GAP IDC/ DMH/] for both nulls and empty text strings
Amend to your needs.
I hope this is helpful