I am trying to fill a new column with String values based on another column (ie the logic). In Excel, I would build a reference table and do a lookup. For arguments sake, lets say i have a list of individual food items:
Item | Meal (new column) |
Bacon | |
Eggs | |
Sandwich | |
Steak |
I want to write a formula to assign the meal. I can get it to run on one item using the following assigned to my new meal column:
IF ([Item] = "Bacon") THEN "Breakfast" Else "Bacon" ENDIF
Entering the name in the new column for failures will help identify when the rules need updating...I just can't figure out how to get all of the rules in one spot.
Thanks
Gio
Solved! Go to Solution.
Hey @Gio ,
You'd be plenty able to do things as you've done prior by using a reference table in another Input tool and by using a Join or Find and Replace based on your common identifier.
Otherwise you're on the right track that within a Formula tool you can build the conditional logic into an expression. The more efficient way to do things will likely depend on how many potential entries you're working with.
Hi @Gio this syntax should work in the formula tool If [Item]="Bacon" then "Breakfast" ELSEIF [Item]="Eggs" THEN "Breakfast" ELSEIF [Item]="Sandwich" then "Lunch" ELSEIF [Item]="Steak" THEN "Dinner" ELSE "" ENDIF
or even
If [Item] In ("Bacon","Eggs") then "Breakfast" ELSEIF [Item]="Sandwich" then "Lunch" ELSEIF [Item]="Steak" THEN "Dinner" ELSE "" ENDIF
Thanks all. The Elseif listing worked great.
I appreciate that it would probably be a lot easier to keep a table elsewhere (I have about 30 items on my listing...), but I want all of the maintenance in one place.
Thanks Again!!
Gio