Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I tried running the below script in the qliksense load editor which involves connecting to qlik web connectors. It is constantly throwing the below error. Could someone please help.
tmp2:
LOAD
[Brand_Name]
,[Name]
,[First_Name]
,[Email_ID]
,Avg([Past_Forecast]) as [Past_Forecast]
,Avg([Curr_Forecast]) as [Curr_Forecast]
,Avg([Variation]) as [Variation]
,Avg([Target_Diff]) as [Target_Diff]
Resident tmp1
Group By [Brand_Name],[Email_ID],[Name],[First_Name];
SUB SetCursor (SetCursor.table, SetCursor.record)
// LET SetCursor.n=1; // don't need this
FOR SetCursor.n = 1 TO NoOfFields('$(SetCursor.table)') // dollar sign expansion + quotes
LET SetCursor.col = FieldName($(SetCursor.n), '$(SetCursor.table)'); // dollar sign expansion + quotes
LET [$(SetCursor.col)] = Peek('$(SetCursor.col)', $(SetCursor.record) - 1, '$(SetCursor.table)'); // dollar sign expansion + quotes where needed
NEXT
LET SetCursor.n = Null();
LET SetCursor.table = Null();
LET SetCursor.col = Null();
END SUB
For n=1 To NoOfRows('tmp2')
CALL SetCursor('tmp2',n);
IF $(Variation)>$(Target_Diff) then
LIB CONNECT TO 'SendEmail';
SendStatus:
SQL SELECT "status", "result", "filesattached"
FROM CSV (header on, delimiter ",", quote """") "CSV_source"
WITH CONNECTION (
QUERY "to" "lakshmi18021994@gmail.com"
,QUERY "cc" "lakshmi18021994@gmail.com"
,QUERY "subject" "Urgent Action Required"
,QUERY "message" "Huge variation in current forecast and last month's forecast has been observed. Please take the necessary steps"
,QUERY "fromName" "Donot Reply"
,QUERY "fromEmail" "lakshmisushmitha.tallapudi@gmail.com"
,QUERY "format" "csv"
);
EndIf
NEXT
whats is the error you are getting?
nothing seems wrong with For n=1 To NoOfRows('tmp2')
Technically the table called tmp2 does not exist in memory.
If I had to guess, tmp1 and tmp2 both have the same field names, so Qlik is auto-concatenating the result to tmp1.
To fix this you should do :
tmp2:
NOCONCATENATE LOAD
[Brand_Name]
,[Name]
,[First_Name]
,[Email_ID]
,Avg([Past_Forecast]) as [Past_Forecast]
,Avg([Curr_Forecast]) as [Curr_Forecast]
,Avg([Variation]) as [Variation]
,Avg([Target_Diff]) as [Target_Diff]
Resident tmp1
Group By [Brand_Name],[Email_ID],[Name],[First_Name];
drop tmp1
---
It is throwing an error because NoOfRows('tmp2') -> tmp2 table does not exist