Need help with formula to flag my records
- 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
Hello,
I have a data set that I need to flag the records based on (4) different criteria type. One of the (4) criterias contain 2 parameters.
- Price <= 75
- Current stock 80% or less of original stock ( data set includes a column for current and original stock)
- Price decrease => $2 (data set includes a column for current and original price)
- Price between 70-80 and MTD loss =>1M
This is the formula I am currently using.
"IF [Price]=<75 OR [Current Stock]/[Original Stock]=<.8 OR [Original Price]-[Current Price]=>2 OR [Price] BETWEEN 70 AND 80 AND [MTD Loss] =>1,000,000) then "Review" else "OK"
Where is my formula going wrong? Thank you,
- Labels:
- Best Practices
- Common Use Cases
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
try
IF [Price] <= 75
OR ([Current Stock] / [Original Stock]) <= 0.8
OR ([Original Price] - [Current Price]) >= 2
OR ([Price] >= 70 AND [Price] <= 80 AND [MTD Loss] >= 1000000)
THEN "Review"
ELSE "OK"
ENDIF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
In Alteryx formulas, you must use the standard comparison operators (<=, >=, <, >, =). Alteryx does not recognize =< or => as valid operators, and you also need to pay attention to parentheses when mixing AND and OR.
Here’s what’s likely going wrong in your expression:
- Invalid comparison operators: You used =< and => instead of <= and >=.
- Missing or misplaced parentheses: When you combine multiple OR/AND conditions, you need parentheses to make sure Alteryx applies the logic you intended.
IF
[Price] <= 75
OR ([Current Stock] / [Original Stock]) <= 0.80
OR ([Original Price] - [Current Price]) >= 2
OR (
[Price] >= 70
AND [Price] <= 80
AND [MTD Loss] >= 1000000
)
THEN
"Review"
ELSE
"OK"
ENDIF
Key Points
- Use <= and >=: For example, Price <= 75 rather than Price =< 75.
- Combine your “Price between 70-80 AND MTD Loss >= 1M” in parentheses so it is treated as a single condition.
- Order of operations: In Alteryx, AND and OR can sometimes produce unexpected results if you do not explicitly group them with parentheses.
This should fix any syntax errors and ensure Alteryx evaluates your conditions correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks for the reply, binuacs and apologies on the late reply. The syntax you provided is correct but its not giving me the results I am looking for. Attached is an example data set where all (4) criteria are met but nothing is showing up in the true anchor. Can you please take a look and let me know if I am missing anything? I appreciate your efforts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Sometimes it is simpler to have 4 different formulas each of each of the conditions.
The minute that you will have 2 or 3 conditions that are meeting the logic then the formula will foul as it is expecting that only one condition can be true to one row.
Try to split it to 4 rows
IF [Price] <= 75
THEN "Review"
ELSE "OK" ENDIF
IF [([Current Stock] / [Original Stock]) <= 0.8
THEN "Review"
ELSE [Fieldname] ENDIF
IF [([Original Price] - [Current Price]) >= 2
THEN "Review"
ELSE [Fieldname] ENDIF
IF ([Price] >= 70 AND [Price] <= 80 AND [MTD Loss] >= 1000000)
THEN "Review"
ELSE [Fieldname] ENDIF
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
The OR is aim to check if the current row is meeting only one of the OR conditions. So the minute that one row meets more than one condition it will foul.
