Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Two IF statements in one formula

mzsweetumz
8 - Asteroid

Hi, 

 

I am trying to get an output of all the cases who were opened for more than 60 days, but is still currently opened and not closed.

 

IIF(DateTimeDiff([Cased Closed],[Cased Opened],'day') >=60, 'Yes','No')

 

This formula works to give me 'Yes' for cases that were opened for 60 days, and 'No' if opened for less than 60 days. However, I want the include the AND cases that are still currently opened.  

 

So the 'Yes' would only show if the cases have been opened for 60 days and is still open.

 

example:

TiffanyLy27_1-1646939316322.png

 

Any help is appreciated!

 

5 REPLIES 5
gabrielvilella
14 - Magnetar

You can write as:

IF DateTimeDiff([Cased Closed],[Cased Opened],'day') >=60 AND [Status] = 'In Progress'

THEN 'Yes'

ELSE 'No'

ENDIF

mzsweetumz
8 - Asteroid

This works, however in my particular case -- some of the cases have a Null value for 'Case Closed' as they're still open.

 

That formula didn't work for this.

 

IF DateTimeDiff([Cased Closed],[Cased Opened],'day') >=60 AND [Status] != 'Closed'

THEN 'Yes'
ELSE 'No'

ENDIF

 

example:

TiffanyLy27_0-1646940710190.png

 

MarqueeCrew
20 - Arcturus
20 - Arcturus

@mzsweetumz ,

 

I'll provide you with a way to use your IIF() logic:

 

 

IIF(DateTimeDiff([Cased Closed],[Cased Opened],'day') >=60 OR [Status] != "Closed", 'Yes','No')

 

 

When cased closed is empty or when cased open is in the future, you should handle these conditions better.  Just a thought.

 

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
gabrielvilella
14 - Magnetar

You need a new condition:

 

IF IsNull([Cased Closed])
THEN 'Yes'
ELSEIF DateTimeDiff([Cased Closed],[Cased Opened],'day') >=60 AND [Status] != 'Closed'
THEN 'Yes'
ELSE 'No'
ENDIF
mzsweetumz
8 - Asteroid

This worked perfectly and it made a lot of sense.

Thank you @gabrielvilella !

Labels