Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Conditional Load Statement

I have a Qlikview app that compares totals from two different file sources when both files are present.  My problem is this:

I would like to view the totals when FILE_A is created but FILE_B does not yet exist.  If FILE_B does not exist then I want to use zero (0) for the FILE_B totals.  If FILE_B does exist, then I want to use the actual FILE_B totals to compare the files.

Is there any way to write a "conditional" load statement that will load FILE_B only if it exists otherwise load 0 to each FILE_B column name?  Something like this:

IF FILE_B EXISTS THEN

      LOAD

           FIELD1,

           FIELD2,

           FIELD3

       FROM FILE_B

ELSE

    LOAD * INLINE [ FIELD1,FIELD2,FIELD3

                               0,0,0

                           ];

Does anyone have any thoughts on this?

Thanks,

Ed T.

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hey Ed,

Try this

set vFile = 'C:\filepath\file.qvd';

let vExists = if(FileSize($(vFile))>0,1,0);

if $(vExists) THEN

LOAD

           FIELD1,

           FIELD2,

           FIELD3

       FROM FILE_B

ELSE

    LOAD * INLINE [ FIELD1,FIELD2,FIELD3

                               0,0,0

                           ];

End If;

I took the example from previous threads regarding this topic.  You may find them helpful as well.

How can I check if a file exists ?

Check file exist via macro

View solution in original post

1 Reply
Anonymous
Not applicable
Author

Hey Ed,

Try this

set vFile = 'C:\filepath\file.qvd';

let vExists = if(FileSize($(vFile))>0,1,0);

if $(vExists) THEN

LOAD

           FIELD1,

           FIELD2,

           FIELD3

       FROM FILE_B

ELSE

    LOAD * INLINE [ FIELD1,FIELD2,FIELD3

                               0,0,0

                           ];

End If;

I took the example from previous threads regarding this topic.  You may find them helpful as well.

How can I check if a file exists ?

Check file exist via macro