<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error in Data load editor script. Could someone please help? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Error-in-Data-load-editor-script-Could-someone-please-help/m-p/1613032#M45633</link>
    <description>&lt;P&gt;HI, I;m still facing this issue. Here is the script modified as suggested by you and the error I'm getting:&lt;/P&gt;&lt;P&gt;ERROR:&lt;/P&gt;&lt;DIV class="headline undefined"&gt;Started loading data&lt;/DIV&gt;&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline edc_error"&gt;The following error occurred:&lt;/DIV&gt;&lt;DIV class="edc_error"&gt;The control statement is not correctly matched with its corresponding start statement&lt;/DIV&gt;&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline edc_error"&gt;The error occurred here:&lt;/DIV&gt;&lt;DIV class="edc_error"&gt;NEXT SetCursor.n&lt;/DIV&gt;&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;Data has not been loaded. Please correct the error and try loading again.&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;SCRIPT:&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;Unqualify *;&lt;/DIV&gt;&lt;P&gt;tmp1:&lt;/P&gt;&lt;P&gt;LOAD&lt;BR /&gt;[Brand Name]as [Brand_Name] ,&lt;BR /&gt;SUM([Forecast1]) as Past_Forecast,&lt;BR /&gt;SUM([Forecast2]) as Curr_Forecast,&lt;BR /&gt;((SUM([Forecast2])-SUM([Forecast1]))/SUM([Forecast1]))*100 AS [Variation]&lt;BR /&gt;FROM [lib://Documents/Data for Prescriptive analysis - No Links.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Forecast1)&lt;/P&gt;&lt;P&gt;GROUP BY [Brand Name],[Month];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;left Join&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;LOAD&lt;BR /&gt;[Brand Name] as [Brand_Name],&lt;BR /&gt;[Name],&lt;BR /&gt;[First Name] as [First_Name],&lt;BR /&gt;[Email ID] as [Email_ID],&lt;BR /&gt;[Target %Diff] as [Target_Diff]&lt;BR /&gt;FROM [lib://Documents/Data for Prescriptive analysis - No Links.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Target);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;tmp2:&lt;/P&gt;&lt;P&gt;LOAD&lt;BR /&gt;[Brand_Name]&lt;BR /&gt;,[Name]&lt;BR /&gt;,[First_Name]&lt;BR /&gt;,[Email_ID]&lt;BR /&gt;,Avg([Past_Forecast]) as [Past_Forecast]&lt;BR /&gt;,Avg([Curr_Forecast]) as [Curr_Forecast]&lt;BR /&gt;,Avg([Variation]) as [Variation]&lt;BR /&gt;,Avg([Target_Diff]) as [Target_Diff]&lt;BR /&gt;Resident tmp1&lt;/P&gt;&lt;P&gt;Group By [Brand_Name],[Email_ID],[Name],[First_Name];&lt;/P&gt;&lt;P&gt;For n=1 To NoOfRows('tmp2')&lt;BR /&gt;CALL SetCursor('tmp2',n);&lt;BR /&gt;If $(Variation) &amp;lt; $(Target_Diff) then // Had to remove variable brackets&lt;BR /&gt;LET vMSg = 'Dear $([First Name])'&lt;BR /&gt;&amp;amp; '&lt;/P&gt;&lt;P&gt;This message is sent from Qlik Sense.';&lt;BR /&gt;/* &amp;amp; '&lt;BR /&gt;This month your demand forecast for the month of $([Month]) is more than 10% of that has been last month'&lt;BR /&gt;&amp;amp; '&lt;BR /&gt;Last month forecast for $([Month]) is $([Last Month Forecast]) and the current month forecast for $([Month]) is $([This Month Forecast]';&lt;/P&gt;&lt;P&gt;CALL SendMail(1, [Email ID],'', 'Huge Demand Forecast Variation',vMsg);&lt;BR /&gt;*/&lt;BR /&gt;endif&lt;BR /&gt;NEXT&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUB SetCursor (SetCursor.table, SetCursor.record)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;FOR SetCursor.n = 1 TO NoOfFields('$(SetCursor.table)') // dollar sign expansion + quotes&lt;BR /&gt;LET SetCursor.col = FieldName($(SetCursor.n), '$(SetCursor.table)'); // dollar sign expansion + quotes&lt;BR /&gt;LET [$(SetCursor.col)] = Peek('$(SetCursor.col)', $(SetCursor.record) - 1, '$(SetCursor.table)'); // dollar sign expansion + quotes where needed&lt;BR /&gt;NEXT SetCursor.n&lt;/P&gt;&lt;P&gt;LET SetCursor.n = Null();&lt;BR /&gt;LET SetCursor.table = Null();&lt;BR /&gt;LET SetCursor.col = Null();&lt;BR /&gt;END SUB&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Aug 2019 19:01:26 GMT</pubDate>
    <dc:creator>Sushmitha_tallapudi</dc:creator>
    <dc:date>2019-08-15T19:01:26Z</dc:date>
    <item>
      <title>Error in Data load editor script. Could someone please help?</title>
      <link>https://community.qlik.com/t5/App-Development/Error-in-Data-load-editor-script-Could-someone-please-help/m-p/1612595#M45601</link>
      <description>&lt;P&gt;I'm trying to run few lines of script in data load editor.&amp;nbsp; But, it is throwing an error.&amp;nbsp; Could anyone please help on where I'm going wrong?&lt;/P&gt;&lt;P&gt;tmp2:&lt;/P&gt;&lt;P&gt;LOAD&lt;BR /&gt;[Brand Name]&lt;BR /&gt;,[Month]&lt;BR /&gt;,[Name]&lt;BR /&gt;,[First Name]&lt;BR /&gt;,[Email ID]&lt;BR /&gt;,Avg([Forecast1]) as [Last Month Forecast]&lt;BR /&gt;,Avg([Forecast2]) as [This Month Forecast]&lt;BR /&gt;,Avg([% Forecast Difference])&lt;BR /&gt;,Avg([Target %Diff])&lt;BR /&gt;Resident tmp1&lt;/P&gt;&lt;P&gt;Group By [Brand Name], [Month],[Email ID],[Name],[First Name];&lt;/P&gt;&lt;P&gt;SUB SetCursor (SetCursor.table, SetCursor.record)&lt;BR /&gt;LET SetCursor.n=1;&lt;BR /&gt;FOR SetCursor.n = 1 TO NoOfFields(SetCursor.table)&lt;BR /&gt;LET SetCursor.col = FieldName(SetCursor.n, SetCursor.table);&lt;BR /&gt;LET [$(SetCursor.col)] = Peek(SetCursor.col, SetCursor.record - 1, SetCursor.table);&lt;BR /&gt;NEXT&lt;/P&gt;&lt;P&gt;LET SetCursor.n = Null();&lt;BR /&gt;LET SetCursor.table = Null();&lt;BR /&gt;LET SetCursor.col = Null();&lt;BR /&gt;END SUB&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For n=1 To NoOfRows('tmp2')&lt;BR /&gt;CALL SetCursor('tmp2',n);&lt;BR /&gt;If $([% Forecast Difference]) &amp;lt; $([Target %Diff]) then&lt;BR /&gt;LET vMSg = 'Dear $([First Name])'&lt;BR /&gt;&amp;amp; '&amp;lt;br&amp;gt;&amp;lt;br&amp;gt; This message is sent from Qlik Sense.';&lt;BR /&gt;/* &amp;amp; '&amp;lt;br&amp;gt; This month your demand forecast for the month of $([Month]) is more than 10% of that has been last month'&lt;BR /&gt;&amp;amp; '&amp;lt;br&amp;gt; Last month forecast for $([Month]) is $([Last Month Forecast]) and the current month forecast for $([Month]) is $([This Month Forecast]';&lt;/P&gt;&lt;P&gt;CALL SendMail(1, [Email ID],'', 'Huge Demand Forecast Variation',vMsg);&lt;BR /&gt;*/&lt;BR /&gt;endif&lt;BR /&gt;NEXT&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 04:57:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Error-in-Data-load-editor-script-Could-someone-please-help/m-p/1612595#M45601</guid>
      <dc:creator>Sushmitha_tallapudi</dc:creator>
      <dc:date>2024-11-16T04:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: Error in Data load editor script. Could someone please help?</title>
      <link>https://community.qlik.com/t5/App-Development/Error-in-Data-load-editor-script-Could-someone-please-help/m-p/1612662#M45612</link>
      <description>&lt;P&gt;Not sure about the other parts of your script, but the below should work.&lt;/P&gt;&lt;P&gt;Also, it would probably make your life easier if you removed the spaces from your field names. Makes things a lot harder to debug.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;tmp2:

LOAD
[Brand Name]
,[Month]
,[Name]
,[First Name]
,[Email ID]
,Avg([Forecast1]) as [Last Month Forecast]
,Avg([Forecast2]) as [This Month Forecast]
,Avg([% Forecast Difference])
,Avg([Target %Diff])
Resident tmp1

Group By [Brand Name], [Month],[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 $(% Forecast Difference) &amp;lt; $(Target %Diff) then // Had to remove variable brackets
        LET vMSg = 'Dear $([First Name])'
        &amp;amp; '

 This message is sent from Qlik Sense.';
        /* &amp;amp; '
 This month your demand forecast for the month of $([Month]) is more than 10% of that has been last month'
        &amp;amp; '
 Last month forecast for $([Month]) is $([Last Month Forecast]) and the current month forecast for $([Month]) is $([This Month Forecast]';

        CALL SendMail(1, [Email ID],'', 'Huge Demand Forecast Variation',vMsg);
        */
    endif
NEXT&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 22:56:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Error-in-Data-load-editor-script-Could-someone-please-help/m-p/1612662#M45612</guid>
      <dc:creator>treysmithdev</dc:creator>
      <dc:date>2019-08-14T22:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Error in Data load editor script. Could someone please help?</title>
      <link>https://community.qlik.com/t5/App-Development/Error-in-Data-load-editor-script-Could-someone-please-help/m-p/1613032#M45633</link>
      <description>&lt;P&gt;HI, I;m still facing this issue. Here is the script modified as suggested by you and the error I'm getting:&lt;/P&gt;&lt;P&gt;ERROR:&lt;/P&gt;&lt;DIV class="headline undefined"&gt;Started loading data&lt;/DIV&gt;&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline edc_error"&gt;The following error occurred:&lt;/DIV&gt;&lt;DIV class="edc_error"&gt;The control statement is not correctly matched with its corresponding start statement&lt;/DIV&gt;&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline edc_error"&gt;The error occurred here:&lt;/DIV&gt;&lt;DIV class="edc_error"&gt;NEXT SetCursor.n&lt;/DIV&gt;&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;Data has not been loaded. Please correct the error and try loading again.&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;SCRIPT:&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="headline undefined"&gt;Unqualify *;&lt;/DIV&gt;&lt;P&gt;tmp1:&lt;/P&gt;&lt;P&gt;LOAD&lt;BR /&gt;[Brand Name]as [Brand_Name] ,&lt;BR /&gt;SUM([Forecast1]) as Past_Forecast,&lt;BR /&gt;SUM([Forecast2]) as Curr_Forecast,&lt;BR /&gt;((SUM([Forecast2])-SUM([Forecast1]))/SUM([Forecast1]))*100 AS [Variation]&lt;BR /&gt;FROM [lib://Documents/Data for Prescriptive analysis - No Links.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Forecast1)&lt;/P&gt;&lt;P&gt;GROUP BY [Brand Name],[Month];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;left Join&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;LOAD&lt;BR /&gt;[Brand Name] as [Brand_Name],&lt;BR /&gt;[Name],&lt;BR /&gt;[First Name] as [First_Name],&lt;BR /&gt;[Email ID] as [Email_ID],&lt;BR /&gt;[Target %Diff] as [Target_Diff]&lt;BR /&gt;FROM [lib://Documents/Data for Prescriptive analysis - No Links.xlsx]&lt;BR /&gt;(ooxml, embedded labels, table is Target);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;tmp2:&lt;/P&gt;&lt;P&gt;LOAD&lt;BR /&gt;[Brand_Name]&lt;BR /&gt;,[Name]&lt;BR /&gt;,[First_Name]&lt;BR /&gt;,[Email_ID]&lt;BR /&gt;,Avg([Past_Forecast]) as [Past_Forecast]&lt;BR /&gt;,Avg([Curr_Forecast]) as [Curr_Forecast]&lt;BR /&gt;,Avg([Variation]) as [Variation]&lt;BR /&gt;,Avg([Target_Diff]) as [Target_Diff]&lt;BR /&gt;Resident tmp1&lt;/P&gt;&lt;P&gt;Group By [Brand_Name],[Email_ID],[Name],[First_Name];&lt;/P&gt;&lt;P&gt;For n=1 To NoOfRows('tmp2')&lt;BR /&gt;CALL SetCursor('tmp2',n);&lt;BR /&gt;If $(Variation) &amp;lt; $(Target_Diff) then // Had to remove variable brackets&lt;BR /&gt;LET vMSg = 'Dear $([First Name])'&lt;BR /&gt;&amp;amp; '&lt;/P&gt;&lt;P&gt;This message is sent from Qlik Sense.';&lt;BR /&gt;/* &amp;amp; '&lt;BR /&gt;This month your demand forecast for the month of $([Month]) is more than 10% of that has been last month'&lt;BR /&gt;&amp;amp; '&lt;BR /&gt;Last month forecast for $([Month]) is $([Last Month Forecast]) and the current month forecast for $([Month]) is $([This Month Forecast]';&lt;/P&gt;&lt;P&gt;CALL SendMail(1, [Email ID],'', 'Huge Demand Forecast Variation',vMsg);&lt;BR /&gt;*/&lt;BR /&gt;endif&lt;BR /&gt;NEXT&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUB SetCursor (SetCursor.table, SetCursor.record)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;FOR SetCursor.n = 1 TO NoOfFields('$(SetCursor.table)') // dollar sign expansion + quotes&lt;BR /&gt;LET SetCursor.col = FieldName($(SetCursor.n), '$(SetCursor.table)'); // dollar sign expansion + quotes&lt;BR /&gt;LET [$(SetCursor.col)] = Peek('$(SetCursor.col)', $(SetCursor.record) - 1, '$(SetCursor.table)'); // dollar sign expansion + quotes where needed&lt;BR /&gt;NEXT SetCursor.n&lt;/P&gt;&lt;P&gt;LET SetCursor.n = Null();&lt;BR /&gt;LET SetCursor.table = Null();&lt;BR /&gt;LET SetCursor.col = Null();&lt;BR /&gt;END SUB&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 19:01:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Error-in-Data-load-editor-script-Could-someone-please-help/m-p/1613032#M45633</guid>
      <dc:creator>Sushmitha_tallapudi</dc:creator>
      <dc:date>2019-08-15T19:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Error in Data load editor script. Could someone please help?</title>
      <link>https://community.qlik.com/t5/App-Development/Error-in-Data-load-editor-script-Could-someone-please-help/m-p/1613038#M45635</link>
      <description>&lt;P&gt;Try this and see if anything worthwhile comes up through the log:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SUB SetCursor (SetCursor.table, SetCursor.record)

    Trace --------------------------- SetCursor: Table: $(SetCursor.table) - Record: $(SetCursor.record) START;
    FOR SetCursor.n = 1 TO NoOfFields('$(SetCursor.table)') // dollar sign expansion + quotes

        Trace ---------------------------- SetCursor: $(SetCursor.table)[$(SetCursor.record)] - Iter($(SetCursor.n)); 

        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
        
        LET vTmp = Peek('$(SetCursor.col)', $(SetCursor.record) - 1, '$(SetCursor.table)');
        Trace ---------------------------- SetCursor: $(SetCursor.table)[$(SetCursor.record)]: $(SetCursor.col): $(vTmp);
    
    NEXT SetCursor.n

    Trace --------------------------- SetCursor: Table: $(SetCursor.table) - Record: $(SetCursor.record) END;

    LET vTmp = Null();
    LET SetCursor.n = Null();
    LET SetCursor.table = Null();
    LET SetCursor.col = Null();

END SUB

Unqualify *;
tmp1:

LOAD
[Brand Name]as [Brand_Name] ,
SUM([Forecast1]) as Past_Forecast,
SUM([Forecast2]) as Curr_Forecast,
((SUM([Forecast2])-SUM([Forecast1]))/SUM([Forecast1]))*100 AS [Variation]
FROM [lib://Documents/Data for Prescriptive analysis - No Links.xlsx]
(ooxml, embedded labels, table is Forecast1)

GROUP BY [Brand Name],[Month];


left Join


LOAD
[Brand Name] as [Brand_Name],
[Name],
[First Name] as [First_Name],
[Email ID] as [Email_ID],
[Target %Diff] as [Target_Diff]
FROM [lib://Documents/Data for Prescriptive analysis - No Links.xlsx]
(ooxml, embedded labels, table is Target);


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];

For n = 1 To NoOfRows('tmp2')

    Trace -------------------------------------------------------- Record: $(n);

    CALL SetCursor('tmp2',n);

    Trace -------------------------------------------------------- Record $(n): Condition(If $(Variation) &amp;lt; $(Target_Diff) then) ;

    If $(Variation) &amp;lt; $(Target_Diff) then // Had to remove variable brackets

        Trace -------------------------------------------------------- Record $(n): Message Sent;
        LET vMSg = 'Dear $([First Name])' &amp;amp; chr(10) &amp;amp; chr(10) &amp;amp;'This message is sent from Qlik Sense.';

    Else

        Trace -------------------------------------------------------- Record $(n): Skip;

    endif

NEXT n&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2019 19:31:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Error-in-Data-load-editor-script-Could-someone-please-help/m-p/1613038#M45635</guid>
      <dc:creator>treysmithdev</dc:creator>
      <dc:date>2019-08-15T19:31:12Z</dc:date>
    </item>
  </channel>
</rss>

