Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Creating a list table based on two or more tables and using Is Null


Hello,

I was wondering if I could get some guidance on how to create a table by creating a new column in my data.  Currently I have:

AdmitDate, (format: M/D/YYYY)

DischargeDate (format: M/D/YYYY)

I want to create a LOS (length of stay) column that is based on the Admit and Discharge Dates:

LOS = DischargeDate - AdmitDate

In addition, if the DischargeDate column is NULL (or empty: no discharge date), then the LOS would be:

LOS= TODAY - AdmitDate.

I want to do this in the load script, but do not know the syntax to use.  Any help is very appreciated.

1 Solution

Accepted Solutions
settu_periasamy
Not applicable

Re: Creating a list table based on two or more tables and using Is Null

Hi,

Try this

If (len (dischargedate)>0,num (dischargedate)-num (admitdate),num (today ())-num (admitdate)) as LOS

4 Replies
settu_periasamy
Not applicable

Re: Creating a list table based on two or more tables and using Is Null

Hi,

Try this

If (len (dischargedate)>0,num (dischargedate)-num (admitdate),num (today ())-num (admitdate)) as LOS

maxgro
Not applicable

Re: Creating a list table based on two or more tables and using Is Null

try with

alt(DischargeDate - AdmitDate, today() - AdmitDate)

Not applicable

Re: Creating a list table based on two or more tables and using Is Null

Thank you, this worked like a charm!

Not applicable

Re: Creating a list table based on two or more tables and using Is Null

This works as well!  Thank you, now I have two options.