Join the Inspire AMA with Joshua Burkhow, March 31-April 4. Ask, share, and connect with the Alteryx community!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Need help with formula to flag my records

CDIns
8 - Asteroid

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,

5 REPLIES 5
binuacs
21 - Polaris

@CDIns 

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
The_Rad_Valentina
9 - Comet
9 - Comet

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:

  1. Invalid comparison operators: You used =< and => instead of <= and >=.
  2. 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.

CDIns
8 - Asteroid

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. 

OTrieger
13 - Pulsar

@CDIns 

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

 

.

OTrieger
13 - Pulsar

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.

Labels
Top Solution Authors