Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Make Zero greater than Negative value Expression help.

Iamironman
6 - Meteoroid

Hello 

For this expression:

IF [Existing Reserve (USD)]>[v_Previous E&O Reserve (USD)]
THEN [v_Previous E&O Reserve (USD)]
ELSE [Existing Reserve (USD)]
ENDIF

 

I am expecting Zero to be greater than Neg value.

 

ZeroGreaterthanNeg.png

 

 

How can I modify the expression to return Zero as being greater than a negative value.

 

Thank you.

7 REPLIES 7
Carolyn
12 - Quasar
12 - Quasar

It's working as built. Swap the > to be a < and it should work as you're thinking

 

You're saying with your values:

If 0 > negative [true]

then return negative [returned in your workflow]

else return 0

endif

 

Garrett_Stoker
8 - Asteroid

Could you provide a bit more explanation to what the issue is? The formula seems to be working as expected as it's returning the negative value given that it's less than the 0. Unless the question is for the logic to swap, in which case the operator would just switch from ">" to "<".

CoG
14 - Magnetar

Depending on the exact data, you can use the Max() or Min() function as well instead of the IF statement.

Iamironman
6 - Meteoroid

Here is another version of my expression.

IF [v_Previous E&O Reserve (USD)]<[Existing Reserve (USD)]
THEN [v_Previous E&O Reserve (USD)]
ELSE [Existing Reserve (USD)]
ENDIF

 

The -2370.05 should be 0

 

Should I take the ABS value of  [v_Previous E&O Reserve (USD)]?

 

 

ZeroGreaterthanNeg2.png

Garrett_Stoker
8 - Asteroid

With this formula, you flipped too many things - it's also giving the correct output based on the provided logic. Translated, here is what the formula is saying:

 

If -2370 is less than 0 (TRUE), then return -2370, otherwise return 0.

 

The two formulas below will return 0:

 

(Flipping the operator)

IF [v_Previous E&O Reserve (USD)]>[Existing Reserve (USD)]
THEN [v_Previous E&O Reserve (USD)]
ELSE [Existing Reserve (USD)]
ENDIF

 

(Flipping the THEN  and ELSE clauses)

IF [v_Previous E&O Reserve (USD)]<[Existing Reserve (USD)]
THEN [Existing Reserve (USD)]
ELSE [v_Previous E&O Reserve (USD)]
ENDIF

Carolyn
12 - Quasar
12 - Quasar

Looking at your new formula, it's working as written:

 

If -2370 < 0 [TRUE]

then put -2370

 

if 75 < 0 [FALSE]

else put 0

 

2024-10-18_11-19-26.png

Carolyn
12 - Quasar
12 - Quasar

Also, in your initial expression, you put:

 

 

[Existing Reserve (USD)]>[v_Previous E&O Reserve (USD)]

 

 

 

In your reply with your 2nd version, you put:

 

 

[v_Previous E&O Reserve (USD)]<[Existing Reserve (USD)]

 

 

 

Those are the same since you switched both the > and the fields. In both cases, the side that's greater is point to the Existing Reserve

 

You need to EITHER change the > to a < and leave the fields in their initial order:

 

[Existing Reserve (USD)] < [v_Previous E&O Reserve (USD)]

 

 

OR swap the order of the fields but leave the > :

 

[v_Previous E&O Reserve (USD)] > [Existing Reserve (USD)]

 

 

Labels