Forum Discussion
o59393
Post Prodigy
6 years agoNested if with power query
Hi all I am doing nested ifs with power query, is there a limit for 2 if statements? I am getting an error when i do more than 2: if [#"[ Container Material ]"] = "Plastic" then "PET" ...
- 6 years ago
Hi o59393 ,
I am not sure what you are trying to achieve but your syntax is incorrect. I've typed in bold the missing part in the below formula:
if [#"[ Container Material ]"] = "Plastic" then "PET" else
if [#"[ Container Material ]"] = "Glass" then "GLASS" else
if [#"[ Container Material ]"] = "Aluminium" then "CAN" else
if [#"[ Container Material ]"] = "Flexible Laminate" then "TETRA"
else null - 6 years agoAs danextian mentioned, you're missing a couple of 'else' statements in your syntax.
You could do this using the 'Conditional Column' button from the 'Add Column' tab in the ribbon, and just click 'Add clause' until you are done. This makes it easier as Excel will take care of the syntax for you and you just need to worry about the correct order and values.
AllisonKennedy
Community Champion
6 years agoAs danextian mentioned, you're missing a couple of 'else' statements in your syntax.
You could do this using the 'Conditional Column' button from the 'Add Column' tab in the ribbon, and just click 'Add clause' until you are done. This makes it easier as Excel will take care of the syntax for you and you just need to worry about the correct order and values.
You could do this using the 'Conditional Column' button from the 'Add Column' tab in the ribbon, and just click 'Add clause' until you are done. This makes it easier as Excel will take care of the syntax for you and you just need to worry about the correct order and values.