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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Check between dates

hi everyone, I was trying adding this kind of lines in my script

(CASE (DO31_DATADELIVERY - DO11_DATADOCUMENT)

WHEN (DO31_DATADELIVERY - DO11_DATADOCUMENT)>3 THEN 'In Tempo'

  WHEN (DO31_DATADELIVERY - DO11_DATADOCUMENT)>7 THEN 'Ritardo'

  END)

but I always receive error. But in the chart if I insert the calculation (DO31_DATADELIVERY - DO11_DATADOCUMENT) as an expression, I obtain the number of days between the two dates.

What I'm doing wrong??

1 Solution

Accepted Solutions
Not applicable
Author

In your SQL statement, can try the following case statement:


SQL SELECT

...
CASE

  WHEN (DO31_DATADELIVERY - DO11_DATADOCUMENT) > 3

      and (DO31_DATADELIVERY - DO11_DATADOCUMENT) < 7 THEN 'In Tempo'

  WHEN (DO31_DATADELIVERY - DO11_DATADOCUMENT) > 7 THEN 'Ritardo'

END as Flag

...

FROM

View solution in original post

21 Replies
Anonymous
Not applicable
Author

Hi,

you should use if instead of case when

if ((D031... -D011...) > 3 then 'Tempo',

   if ((do31.. - D011...) > 7 then 'Ritardo'
)) as Text

Hope it helps

Not applicable
Author

I don't think is the correct syntax...it's not working...

Anonymous
Not applicable
Author

what is the error? you need to put the above script when you read the table

Table:

load

D031....,

D011...

if (D031-D011 > 3, ...

..

resident abc;

WHat are D031... and D011? Fields within a table?

Can you send example?

Not applicable
Author

DO31 and DO11 are two tables already loaded within the script, so I'm using two fields: DO31_DATADELIVERY and DO11_DATADOCUMENT which are already present in my script. I think it's just a matter of writing properly the 'case when' syntax...

Not applicable
Author

Try this:

If([DO31_DATADELIVERY - DO11_DATADOCUMENT]>7, 'In Tempo',

      If([DO31_DATADELIVERY - DO11_DATADOCUMENT]>3, 'Ritardo'))

  as Flag

Not applicable
Author

Note that I also switched the condition to evaluate if field is larger than 7 before 3. If you have the condition evaluate if its over 3, then everything over 3 will be in Tempo. You can also expand the expression to test if field is larger then 3 and smaller than 7 for Tempo like this:

If([DO31_DATADELIVERY - DO11_DATADOCUMENT]>3 and [DO31_DATADELIVERY - DO11_DATADOCUMENT]<7, 'In Tempo', If([DO31_DATADELIVERY - DO11_DATADOCUMENT]>3, 'Ritardo')) as Flag

Not applicable
Author

no it's not working...I quite sure that in script I must use the CASE WHEN syntax instead of  IF...

Not applicable
Author

[DO31_DATADELIVERY] and [DO11_DATADOCUMENT] are separate fields that you are subtracting or is it one field called [DO31_DATADELIVERY - DO11_DATADOCUMENT]?

Anonymous
Not applicable
Author

there is no case syntax

you need to bring the two table in relation. is there an id which can be used?

TEST:

noconcatenate load
ID
D031_DATADELIVERY
reiseent D031

Left join(TEST)

ID

D011_DATADOCUMENT

resident D011

TEST1:

noconcatenate load

D031_DATADELIVERY,

D011_DATADOCUMENT,

if (D031... - D011 > 3, 'Tempo'

resident TEST;

drop table TEST

this is not exactly the script you need. it should give you an idea!

I am missing CASE when also. It would be nice to have!