Forum Discussion
Toni_LW
2 years agoRegular Visitor
I need help to create a custom column using an IF statement based on two columns
I'm not sure if this the best solution, I may be making it more complicated than it needs to be. I have two coloumns: [Dialog identifier] [Dialog value] Data example: [Dialog identifier] ...
- 2 years ago
Toni_LW
Add a custom column in Power Query with the following code. I entered Null at the end if non of the conditions are met, you can replace it with anything:= let identifier = [Dialog identifier], value = [Dialog value], menu80Condition = Text.EndsWith(identifier, "Menu_80"), menu87Condition = Text.EndsWith(identifier, "Menu_87"), result = if menu80Condition and value = "1" then "Deflection" else if menu80Condition and value = "2" then "Spoke to an Agent" else if menu80Condition and value = "noinput" then "No Input" else if menu80Condition and value = "nomatch" then "No Match" else if menu87Condition and value = "1" then "Deflection" else if menu87Condition and value = "2" then "Deflection" else if menu87Condition and value = "3" then "Spoke to an Agent" else if menu87Condition and value = "noinput" then "No Input" else if menu87Condition and value = "nomatch" then "No Match" else null in result)
Toni_LW
2 years agoRegular Visitor
Both of the columns are in a single table.
Fowmy
2 years agoSuper User
Toni_LW
Add a custom column in Power Query with the following code. I entered Null at the end if non of the conditions are met, you can replace it with anything:
= let
identifier = [Dialog identifier],
value = [Dialog value],
menu80Condition = Text.EndsWith(identifier, "Menu_80"),
menu87Condition = Text.EndsWith(identifier, "Menu_87"),
result =
if menu80Condition and value = "1" then "Deflection"
else if menu80Condition and value = "2" then "Spoke to an Agent"
else if menu80Condition and value = "noinput" then "No Input"
else if menu80Condition and value = "nomatch" then "No Match"
else if menu87Condition and value = "1" then "Deflection"
else if menu87Condition and value = "2" then "Deflection"
else if menu87Condition and value = "3" then "Spoke to an Agent"
else if menu87Condition and value = "noinput" then "No Input"
else if menu87Condition and value = "nomatch" then "No Match"
else null
in
result)- Toni_LW2 years agoRegular Visitor
Thank you!