Alteryx Designer Desktop Discussions

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

Need some help writing Conditional Formulas

JPAEP
7 - Meteor

I'm sure this is probably pretty easy, but I'm struggling with the "1" in the middle of the formula. But how would I write this in Alteryx?

 

=IF(O2-K2=0,1,(O2-K2))

 

Thanks in advance!
Jordan

17 REPLIES 17
PhilipMannering
16 - Nebula
16 - Nebula

It would write this as,

IF [Field_O]=[Field_K] THEN 1 ELSE [Field_O]-[Field_K] ENDIF

 

IraWatt
17 - Castor
17 - Castor

Hey @JPAEP,

Is this what your looking for:

IF ([O2]-[K2]) = 0 THEN 1 ELSE [O2]-[K2] ENDIF

IraWatt_0-1654535972503.png

Any questions or issues please ask :)
HTH!
Ira

 

PhilipMannering
16 - Nebula
16 - Nebula

You can also use the ternary formula,

IIF ([Field_O] = [Field_K], 1, [Field_O] - [Field_K])
binuacs
20 - Arcturus

@JPAEP another way of doing this with the IIF statement

IIF([O2]-[K2]=0,1,[O2]-[K2])

 

JPAEP
7 - Meteor

I'm super close on this, but it doesn't like the ending on these. See below. Even if I bracket the last part, it still will not run.

 

JPAEP_0-1654537188290.png

 

IraWatt
17 - Castor
17 - Castor

@JPAEP you will need to convert your data to number as its currently text try:

IIF(toNumber([O2])-toNumber([K2])=0,1,toNumber([O2])-toNumber([K2]))

 Or just change there data type using a select tool

JPAEP
7 - Meteor

Thank you sir!

IraWatt
17 - Castor
17 - Castor

No worries @JPAEP ! :) 

JPAEP
7 - Meteor

This was close getting me there, then I realized it was date related data. So I used the DateTimeDiff formula and it gets me really close, I just need anything that is a 0 to turn into a 1. Can I do the DateTimeAdd with the Diff to get the intended result? Formula below.

 

DateTimeDiff([CON Start],[CON Finish],'days') 

Labels