Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load Script change by date

Greetings,

I am trying to load two different sets of data depending on the date. From the first business day of the month to some date around the 14th of the month, one set of data is used. This is preliminary data.  From some date around the 14th of the month to the last business day of the month, different data is used.  This is Final data.  I would put an update date into a SQL table when the data is updated mid month.  That way I can check to see if the final data has been updated.

Is there a way to read the update date and then load the proper set of data?

I am thinking "IF Month(today) is greater than Month(update date) then load the final data, else load the preliminary data.

Thanks,

Frank

1 Solution

Accepted Solutions
marcus_sommer

Try it in this way:

If filetime('\\Server\working\Inputs\Preliminary.csv') > filetime('\\Server\working\Inputs\Final.txt') then

     SELECT * FROM "MyDB".dbo.Preliminary;
else

     SELECT * FROM "MyDB".dbo.Final;
end if

- Marcus

View solution in original post

9 Replies
marcus_sommer

Something like this:

if day(today()) <= 14 then

     load * from preliminary;

else

     load * from final;

end if

- Marcus

florentina_doga
Partner - Creator III
Partner - Creator III

load data and add this

if(day(today()>15,1,0) as flag

Not applicable
Author

I have a second part to this question.  Is it possible to check the modification date of a file from the load script? 

marcus_sommer

You could query this with the qv-filefunctions like:

filetime('YourFile')

- Marcus

Not applicable
Author

This is what I am trying to do.  I don't think I have the correct syntax.

If(filetime('\\Server\working\Inputs\Preliminary.csv') > filetime('\\Server\working\Inputs\Final.txt'),

SELECT *
FROM "MyDB".dbo.Preliminary;
,

SELECT*
FROM "MyDB".dbo.Final;
);

marcus_sommer

Try it in this way:

If filetime('\\Server\working\Inputs\Preliminary.csv') > filetime('\\Server\working\Inputs\Final.txt') then

     SELECT * FROM "MyDB".dbo.Preliminary;
else

     SELECT * FROM "MyDB".dbo.Final;
end if

- Marcus

rubenmarin

Hi Frank, there are two 'If', in this case you're using 'If' as script control sentence, so you must use the syntaxis provided by Marcus.

- Script control statement: If...then...elseif...endif

https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/ScriptControlStatement...

- Conditional function: In format If(Condition, then, else)

https://help.qlik.com/en-US/qlikview/12.0/Subsystems/Client/Content/Scripting/ConditionalFunctions/i...

Not applicable
Author

Thank you Marcus.  I looked at you earlier reply and it worked after using that syntax.  I just need to load that into a table.  Whenever I put a table name (MyTable:) in front of it, it errors out.

rubenmarin

Hi Frank, try setting the name in each block of the 'IF':

If filetime('\\Server\working\Inputs\Preliminary.csv') > filetime('\\Server\working\Inputs\Final.txt') then

     TableName:

     SELECT * FROM "MyDB".dbo.Preliminary;
else

     TableName:

     SELECT * FROM "MyDB".dbo.Final;
end if