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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
rittermd
Master
Master

What is wrong with this code?

The comma before 'Yes' indicates a problem.  But I can't figure out what is wrong here.

Trigger:
LOAD client_id,
dm_name,
last_dm_update_date
FROM
last_update.qvd(
qvd)
;

If (Date(last_dm_update_date,'yyyy-MM-dd') = Date(today(),'yyyy-MM-dd'),'Yes','No') as vpublish;

1 Solution

Accepted Solutions
sunny_talwar

I don't know why you need to use date formatting within the if statement:

Try this:

If(last_dm_update_date = Today(), 'Yes', 'No') as vpublish

Also why is this outside of the LOAD statement? is this part of another table?

May be you need the code to be like this:

Trigger:

LOAD *,

          If(last_dm_update_date = Today(), 'Yes', 'No') as vpublish;
LOAD client_id,
          dm_name,
          last_dm_update_date
FROM
last_update.qvd(qvd
);

If for some reason your last_dm_update_date is not read as date and is in YYYY-MM-DD format, then you can do something like this:

Trigger:

LOAD *,

          If(last_dm_update_date = Today(), 'Yes', 'No') as vpublish;
LOAD client_id,
          dm_name,
          Date(Date#(last_dm_update_date, 'YYYY-MM-DD'), 'YYYY-MM-DD') as last_dm_update_date
FROM
last_update.qvd(qvd
);

View solution in original post

3 Replies
sunny_talwar

I don't know why you need to use date formatting within the if statement:

Try this:

If(last_dm_update_date = Today(), 'Yes', 'No') as vpublish

Also why is this outside of the LOAD statement? is this part of another table?

May be you need the code to be like this:

Trigger:

LOAD *,

          If(last_dm_update_date = Today(), 'Yes', 'No') as vpublish;
LOAD client_id,
          dm_name,
          last_dm_update_date
FROM
last_update.qvd(qvd
);

If for some reason your last_dm_update_date is not read as date and is in YYYY-MM-DD format, then you can do something like this:

Trigger:

LOAD *,

          If(last_dm_update_date = Today(), 'Yes', 'No') as vpublish;
LOAD client_id,
          dm_name,
          Date(Date#(last_dm_update_date, 'YYYY-MM-DD'), 'YYYY-MM-DD') as last_dm_update_date
FROM
last_update.qvd(qvd
);

Peter_Cammaert
Partner - Champion III
Partner - Champion III

This IF construction looks like part of a LOAD statement (because of the AS keyword) but there isn't any embedding LOAD to be found. That means that you are using IF as a control statement and the syntax for that one is different from the syntax of the IF() function.

If you want a new field in table Trigger, write it like this:

Trigger:
LOAD client_id,
     dm_name,
     last_dm_update_date,

       IF (floor(last_dm_update_date) = floor(today()),'Yes','No') as vpublish

FROM last_update.qvd(qvd);

Not applicable

In which place, you are using IF statement ?

Do you need to add into precedent load ? can you please post full script snippet ?