Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Issue in nested if

Hi,

Can anyone please help me with this issue in script.

(floorIF(ISNULL(FIFTH_DOC_SENT_DATETIME),IF(ISNULL(FOURTH_DOC_SENT_DATETIME),

 
IF(ISNULL(THIRD_DOC_SENT_DATETIME),IF(ISNULL(SECOND_DOC_SENT_DATETIME),

 
FIRST_DOC_SENT_DATETIME,SECOND_DOC_SENT_DATETIME))))),'MM/DD/YYYY') as [Last Doc Sent Date]

This code works fine until THIRD_DOC_SENT_DATETIME, FOURTH_DOC_SENT_DATETIME, FIFTH_DOC_SENT_DATETIME are null.

But if there is data for THIRD_DOC_SENT_DATETIME or FOURTH_DOC_SENT_DATETIME or FIFTH_DOC_SENT_DATETIME. How should I give the condition in if clause. "If" takes only two parameters right.

Thanks in advance,

Regards,
Aditya

2 Replies
maxgro
MVP
MVP

regarding syntax I think this is correct

date(floor( 

IF(ISNULL(FIFTH_DOC_SENT_DATETIME),

IF(ISNULL(FOURTH_DOC_SENT_DATETIME),

IF(ISNULL(THIRD_DOC_SENT_DATETIME),

IF(ISNULL(SECOND_DOC_SENT_DATETIME),

  FIRST_DOC_SENT_DATETIME,

  SECOND_DOC_SENT_DATETIME))))),'MM/DD/YYYY') as [Last Doc Sent Date]

but is better if you explain your requirement; do you want the first not null date? maybe

date(

     floor(

          alt(FIFTH_DOC_SENT_DATETIME, FOURTH_DOC_SENT_DATETIME, ...........),

          )

     'MM/DD/YYYY') as [Last Doc Sent Date]

john_s_w_wood
Creator
Creator

May also be worth a look at what the alt function does?