If statements with multiple columns
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi everyone, lets say I want to make an If statement like the following
If [Column Z] = "H" and [Column A] = ([column B],[column C],[column D],[column E],[column F],[column G],[column H]) then "X" else "Y" endif
How would the syntax work for this in alteryx? Without doing some sort of gigantic string of elseIf's?
The idea of course being that if column Z contains the value "H" and column A is equal of any one of lets say 10-20 columns.
Thanks
Solved! Go to Solution.
- Labels:
- Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I would do this
If [Column Z] = "H" and (
[Column A] = [column B]
or [Column A] = [column C]
or [Column A] = [column D]
or [Column A] = [column E]
or [Column A] = [column F]
or [Column A] = [column G]
or [Column A] = [column H]
)
then "X"
else "Y"
endif
It feels a bit long, but you're only writing it once :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Nice solution @AGilbert I was thinking about IN when I posted mine, but I didn't have the time to test.
Your filter is interesting though, I never write the full IF syntax in a filter, I just use the raw condition like this (but either way works):
[Z] = 'H' and [A] in ([B],[C],[D],[E],[F],[G])
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@cmcclellan I agree that the full if statement is unnecessary. I should take time to tighten up my logic blocks but sometimes the ideas just fly, ya know!?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks @AGilbert , an "IN" statement is exactly what I was looking for.
