I am trying to think of a way to assign a value based on two other columns. See below. This site is great. Thank you in advance for your help
Partner | Category | Product Code | |
North | Winter | Red | |
South | Summer | Yellow | |
East | Summer | Magenta | |
North | Summer | Orange | |
South | Fall | Violet | |
East | Fall | White | |
North | Winter | Red | |
West | Fall | Purple | |
South | Summer | Yellow | |
East | Summer | Magenta | |
South | Spring | Pink | |
West | Fall | Purple | |
North | Spring | Blue | |
If Partner=North and Category =Winter then Product Code = Red | |||
If Partner=North and Category =Summer then Product Code = Orange | |||
etc…... |
Hey @amorej, you were just about there with what you had typed out! You first need to bring a Formula tool into your data stream and give the new expression a name (or you can edit an existing one), from the pane under 'Output Column'. There's just a few key tweaks to format the expression as needed for Alteryx:
1 - Wrap field names in square brackets e.g. Partner ought to be [Partner]
2 - The values that you are checking for (North, South, Summer, Winter etc) need to be within quotes, so [Partner] = "Winter" or [Partner] = 'Winter' for example. If you're checking numeric fields then you don't use quotes, would just be the number itself like [Total] = 100
3 - If there are multiple possible outcomes (i.e. a large list of Partner/Category combinations), then you use 'elseif' to essentially restart your if statement each time
4 - To finalise your if statement, you need to provide an 'else' which is essentially saying 'if my values don't match any of the combinations to output the outcomes I've listed above, just do this...' (in my example this is 'White', which is applied to everything where the values don't match a specific combination I've set out)
5 - Use 'endif' to actually finish your if statement
More great resources here if you want to learn more about expressions in Alteryx: https://community.alteryx.com/t5/Interactive-Lessons/tkb-p/interactive-lessons/label-name/writing%20...