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

If condition fails reload should exit from the script

Hi Experts,

I have a table Employee which contains dtmAddedOn (getdate field with current date).I do fetch data from SQLSERVER to QVD Generator.

If i don't have Current date  in dtmAddedOn column ,my QVD  Generator should not Reload the script.it has to exit the script.

Could you please suggest me some way to sort out the issue.


Intention of the event of refresh failure we are at least able to retain a day’s old data and don’t wipe out data completely from the dashboard

Inadvance

Thank you

8 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Before executing the store instruction, do a query to select dtmAddedOn and count it (something like select count(dtmAddedOn) from ....

then with peek function verify that a value exists, store the result in a variable and with it use an if condition before the store.

Hope it is clear

Anonymous
Not applicable
Author

Can i get some example on this one!!

alexandros17
Partner - Champion III
Partner - Champion III

Tab1:
LOAD * Inline [
Fld1, Fld2, Date
a,aa,
b,bb,
c,cc,
]
;

// As you can see there isn't any date.

Temp:
LOAD Sum(If(IsNull(Date) or Trim(Date)='',0,1)) as dates Resident Tab1;
Let totDates = Peek('dates',0,'Temp');

IF $(totDates) > 0 then
STORE * from Tab1 into tab.qvd;
ENDIF 

Anonymous
Not applicable
Author

I tried this one but no luck.Could you pls guide whts wrong in the below Load.In all the case my script is getting executed.

Tab1:

LOAD Date(Date#([dtmAddedOn],'YYYY-MM-DD'),'DD/MM/YYYY') as dtmAddedOn;

SQL SELECT CAST(dtmAddedOn As DATE)  as dtmAddedOn

FROM "Sales_UAT".dbo."Fact_Opportunity";

Temp:

LOAD Sum(If(IsNull(dtmAddedOn) or Trim(dtmAddedOn)='',0,1)) as dates Resident Tab1;

Let totDates = Peek('dates',0,'Temp');

IF $(totDates) > 0 then

STORE * from Tab1 into tab.qvd;

ENDIF

alexandros17
Partner - Champion III
Partner - Champion III

Try with:

Tab1:

SELECT Count(dtmAddedOn)  as dtmAddedOn

FROM "Sales_UAT".dbo."Fact_Opportunity" where not dtmAddedOn is null;

Let totDates = Peek('dtmAddedOn',0,'Tab1');

IF $(totDates) > 0 then

STORE * from Tab1 into tab.qvd;

ENDIF

let me know

sasiparupudi1
Master III
Master III

Tab1:

LOAD Date(Date#([dtmAddedOn],'YYYY-MM-DD'),'DD/MM/YYYY') as dtmAddedOn;

SQL SELECT CAST(dtmAddedOn As DATE)  as dtmAddedOn

FROM "Sales_UAT".dbo."Fact_Opportunity";

Temp:

LOAD count(dtmAddedOn) as dateCount Resident Tab1 where len(trim(dtmAddedOn))>0;

Let totDates = Peek('dateCount',0,'Temp');

IF $(totDates) > 0 then

STORE * from Tab1 into tab.qvd;

ENDIF

Kushal_Chawda

try,

Tab1:

LOAD Date(Date#([dtmAddedOn],'YYYY-MM-DD'),'DD/MM/YYYY') as dtmAddedOn;

SQL SELECT CAST(dtmAddedOn As DATE)  as dtmAddedOn

FROM "Sales_UAT".dbo."Fact_Opportunity";

Temp:

LOAD distinct sum(If(len(trim(dtmAddedOn))=0,0,1)) as dates Resident Tab1;

Let totDates = Peek('dates',0,'Temp');

IF len('$(totDates)' ) > 0 then

STORE * from Tab1 into tab.qvd;

ENDIF

Anonymous
Not applicable
Author

Thanks for the prompt response

No luck,One thing I want to clear that Fact_Opportunity table contains all the records have same date..I mean 1000 Records have the same date

After condition failing  script is getting executed.Some where its has to exit script right

Header 1Header 2dtmAddedon
XYZDelhi09/08/20115
ABCMUMBAI09/08/20115