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

Error in the QlikSense Load Editor Script. Please help!

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.

The following error occurred:
 
 
The error occurred here:
For n=1 To NoOfRows('tmp2')
 
 
My Script:
 
 

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

2 Replies
dplr-rn
Partner - Master III
Partner - Master III

whats is the error you are getting?

nothing seems wrong with For n=1 To NoOfRows('tmp2')

Sazabi
Creator
Creator

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