<?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: SUM within Loadscript = Invalid Expression in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/SUM-within-Loadscript-Invalid-Expression/m-p/2034428#M85243</link>
    <description>&lt;P&gt;Hi, many thanks for your response.&lt;/P&gt;
&lt;P&gt;I hadn't used group by before, but think I have worked it out?&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;[Line Hours]:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;NoConcatenate&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Load &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;[VGW03],&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;[BMSCH],&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;[GMNGA],&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;SUM (([VGW03] / [BMSCH]) * [GMNGA]) /60 as [Line Hours]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;// Lab (Min) / Base QTY * Confirmed QTY &lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Resident [ZUK_CAPU]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Group by [VGW03], [BMSCH], [GMNGA];&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Though my calculation still looks to differ to if I just use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;SUM (([VGW03] / [BMSCH]) * [GMNGA]) /60 as [Line Hours]&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;as a calculated&amp;nbsp;measure in a table?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Any thoughts/ideas?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Again , thanks for your time and advice.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Regards Daryn&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Feb 2023 12:58:03 GMT</pubDate>
    <dc:creator>Daryn</dc:creator>
    <dc:date>2023-02-06T12:58:03Z</dc:date>
    <item>
      <title>SUM within Loadscript = Invalid Expression</title>
      <link>https://community.qlik.com/t5/App-Development/SUM-within-Loadscript-Invalid-Expression/m-p/2034345#M85237</link>
      <description>&lt;P&gt;Hello to all and thanks for taking the time to read/assist with this issue.&lt;/P&gt;
&lt;P&gt;I have a sum that gives the right result in a table.&lt;/P&gt;
&lt;P&gt;sum (([VGW03] / [BMSCH]) * [GMNGA]) /60&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create that value as a field I can use, so assumed I could do this in the load script.&lt;/P&gt;
&lt;P&gt;When I try I get an 'invalid expression' load script error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My load script is (have removed the full SQL address);&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;LIB CONNECT TO 'Microsoft_SQL_Server(uk_daryn.bray)';&lt;/P&gt;
&lt;P&gt;LOAD&lt;BR /&gt;[MANDT],&lt;BR /&gt;[RUECK],&lt;BR /&gt;[RMZHL],&lt;BR /&gt;[VORNR],&lt;BR /&gt;Date(Date#([ERSDA], 'YYYYMMDD') ) AS [ERSDA],&lt;BR /&gt;[ERNAM],&lt;BR /&gt;Date(Date#([BUDAT], 'YYYYMMDD') ) AS [BUDAT],&lt;BR /&gt;[AFRU_TEXT],&lt;BR /&gt;[GMNGA],&lt;BR /&gt;[XMNGA],&lt;BR /&gt;[SMENG],&lt;BR /&gt;[ERZET],&lt;BR /&gt;[STOKZ],&lt;BR /&gt;[STZHL],&lt;BR /&gt;[AUFNR],&lt;BR /&gt;[PLGRP],&lt;BR /&gt;[DISPO],&lt;BR /&gt;[FEVOR],&lt;BR /&gt;Date(Date#([GLTRS], 'YYYYMMDD') ) AS [GLTRS],&lt;BR /&gt;Date(Date#([LTRMI], 'YYYYMMDD') ) AS [LTRMI],&lt;BR /&gt;[MATNR],&lt;BR /&gt;[DWERK],&lt;BR /&gt;[STATU],&lt;BR /&gt;[PLPO_TEXT],&lt;BR /&gt;[BMSCH],&lt;BR /&gt;[VGW02],&lt;BR /&gt;[VGW03],&lt;BR /&gt;[ARBID],&lt;BR /&gt;[ARBPL],&lt;BR /&gt;[KTEXT],&lt;BR /&gt;[MAKTX],&lt;BR /&gt;[PLANR],&lt;BR /&gt;[STPRS], &lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#008000"&gt;SUM (([VGW03] / [BMSCH]) * [GMNGA] /60) as [Line Hours],&lt;/FONT&gt;&lt;BR /&gt;// Lab (Min) / Base QTY * Confirmed QTY&lt;/P&gt;
&lt;P&gt;if([LTRMI] &amp;gt; [GLTRS] ,'LATE',&lt;BR /&gt;if([LTRMI] &amp;lt; [GLTRS] ,'EARLY',&lt;BR /&gt;if([LTRMI] = [GLTRS] ,'ON TIME'))) as [Production Order Finish Status],&lt;/P&gt;
&lt;P&gt;ApplyMap ('Map1', ([ARBPL]), '-Unkown-') as Category,&amp;nbsp;&lt;BR /&gt;ApplyMap ('Map2', ([ARBPL]), '-Unkown-') as Category2,&lt;BR /&gt;ApplyMap ('Map3', ([FEVOR]), '-Unkown-') as SchedulerDesc,&lt;BR /&gt;ApplyMap ('Map4', ([FEVOR]), '-Unkown-') as Channel,&lt;BR /&gt;ApplyMap ('Map5', ([FEVOR]), '-Unkown-') as Product_Family_1;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[ZUK_CAPU]:&lt;BR /&gt;SELECT MANDT,&lt;BR /&gt;RUECK,&lt;BR /&gt;RMZHL,&lt;BR /&gt;VORNR,&lt;BR /&gt;ERSDA,&lt;BR /&gt;ERNAM,&lt;BR /&gt;BUDAT,&lt;BR /&gt;"AFRU_TEXT",&lt;BR /&gt;GMNGA,&lt;BR /&gt;XMNGA,&lt;BR /&gt;SMENG,&lt;BR /&gt;ERZET,&lt;BR /&gt;STOKZ,&lt;BR /&gt;STZHL,&lt;BR /&gt;AUFNR,&lt;BR /&gt;PLGRP,&lt;BR /&gt;DISPO,&lt;BR /&gt;FEVOR,&lt;BR /&gt;GLTRS,&lt;BR /&gt;LTRMI,&lt;BR /&gt;MATNR,&lt;BR /&gt;DWERK,&lt;BR /&gt;STATU,&lt;BR /&gt;"PLPO_TEXT",&lt;BR /&gt;BMSCH,&lt;BR /&gt;VGW02,&lt;BR /&gt;VGW03,&lt;BR /&gt;ARBID,&lt;BR /&gt;ARBPL,&lt;BR /&gt;KTEXT,&lt;BR /&gt;MAKTX,&lt;BR /&gt;PLANR,&lt;BR /&gt;STPRS&lt;BR /&gt;FROM "CO_DB_01".dbo."ZUK_CAPU" Where ([DWERK] ='UK01') AND (GMNGA &amp;lt;&amp;gt; 0);&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;The above script works okay without the line;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000"&gt;SUM (([VGW03] / [BMSCH]) * [GMNGA] /60) as [Line Hours],&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;It will also load with that line but without SUM in front of it (but the value of [Line Hours] is then not correct).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;The error I get is below, but strangely does not appear to point at the SUM line?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000"&gt;--------------------------------------------------------------------------------------------------------------&lt;/FONT&gt;&lt;/P&gt;
&lt;DIV class="headline undefined"&gt;
&lt;DIV class="headline undefined"&gt;&lt;FONT color="#0000FF"&gt;Started loading data&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class=""&gt;&lt;FONT color="#0000FF"&gt;Map1 &amp;lt;&amp;lt; Sheet1 Lines fetched: 56 Map2 &amp;lt;&amp;lt; Sheet1 Lines fetched: 56 Map3 &amp;lt;&amp;lt; Sheet1 Lines fetched: 58 Map4 &amp;lt;&amp;lt; Sheet1 Lines fetched: 58 Map5 &amp;lt;&amp;lt; Sheet1 Lines fetched: 58 OTIF Finished Goods &amp;lt;&amp;lt; OTIF Finished Goods Lines fetched: 70.021&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class=""&gt;&lt;FONT color="#0000FF"&gt;Connected&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class=""&gt;&lt;FONT color="#0000FF"&gt;ZUK_CAPU &amp;lt;&amp;lt; QueryResult Script error: Invalid expression&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="headline edc_error"&gt;&lt;FONT color="#0000FF"&gt;The following error occurred:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="edc_error"&gt;&lt;FONT color="#0000FF"&gt;Invalid expression&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="empty edc_error"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="headline edc_error"&gt;&lt;FONT color="#0000FF"&gt;The error occurred here:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="edc_error"&gt;&lt;FONT color="#0000FF"&gt;[ZUK_CAPU]: SELECT MANDT, RUECK, RMZHL, VORNR, ERSDA, ERNAM, BUDAT, "AFRU_TEXT", GMNGA, XMNGA, SMENG, ERZET, STOKZ, STZHL, AUFNR, PLGRP, DISPO, FEVOR, GLTRS, LTRMI, MATNR, DWERK, STATU, "PLPO_TEXT", BMSCH, VGW02, VGW03, ARBID, ARBPL, KTEXT, MAKTX, PLANR, STPRS &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="edc_error"&gt;&lt;FONT color="#0000FF"&gt;FROM "CO_DB_01".dbo."ZUK_CAPU" Where ([DWERK] ='UK01') AND (GMNGA &amp;lt;&amp;gt; 0)&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="headline edc_error"&gt;&lt;FONT color="#0000FF"&gt;The following error occurred:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="edc_error"&gt;&lt;FONT color="#0000FF"&gt;Invalid expression&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="empty undefined"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="headline undefined"&gt;&lt;FONT color="#0000FF"&gt;Data has not been loaded. Please correct the error and try loading again.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;--------------------------------------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help or advice would be appreciated, thanks in advance.&lt;/P&gt;
&lt;P&gt;Regards Daryn&lt;/P&gt;
&lt;P&gt;ps.. I also noticed that the error doesn't show the last ';' but it is in the loadscript. Assume that is just the way it reports.&lt;/P&gt;
&lt;P&gt;FROM "CO_DB_01".dbo."ZUK_CAPU" Where ([DWERK] ='UK01') AND (GMNGA &amp;lt;&amp;gt; 0);&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 09:25:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/SUM-within-Loadscript-Invalid-Expression/m-p/2034345#M85237</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2023-02-06T09:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: SUM within Loadscript = Invalid Expression</title>
      <link>https://community.qlik.com/t5/App-Development/SUM-within-Loadscript-Invalid-Expression/m-p/2034366#M85238</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;When you use aggregation function like sum, max, min, you need to use group by the remaining columns..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope it helps&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 10:17:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/SUM-within-Loadscript-Invalid-Expression/m-p/2034366#M85238</guid>
      <dc:creator>MayilVahanan</dc:creator>
      <dc:date>2023-02-06T10:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: SUM within Loadscript = Invalid Expression</title>
      <link>https://community.qlik.com/t5/App-Development/SUM-within-Loadscript-Invalid-Expression/m-p/2034428#M85243</link>
      <description>&lt;P&gt;Hi, many thanks for your response.&lt;/P&gt;
&lt;P&gt;I hadn't used group by before, but think I have worked it out?&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;[Line Hours]:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;NoConcatenate&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Load &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;[VGW03],&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;[BMSCH],&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;[GMNGA],&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;SUM (([VGW03] / [BMSCH]) * [GMNGA]) /60 as [Line Hours]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;// Lab (Min) / Base QTY * Confirmed QTY &lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Resident [ZUK_CAPU]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Group by [VGW03], [BMSCH], [GMNGA];&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Though my calculation still looks to differ to if I just use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;SUM (([VGW03] / [BMSCH]) * [GMNGA]) /60 as [Line Hours]&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;as a calculated&amp;nbsp;measure in a table?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Any thoughts/ideas?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Again , thanks for your time and advice.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;Regards Daryn&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 12:58:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/SUM-within-Loadscript-Invalid-Expression/m-p/2034428#M85243</guid>
      <dc:creator>Daryn</dc:creator>
      <dc:date>2023-02-06T12:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: SUM within Loadscript = Invalid Expression</title>
      <link>https://community.qlik.com/t5/App-Development/SUM-within-Loadscript-Invalid-Expression/m-p/2034447#M85246</link>
      <description>&lt;P&gt;Hi, you don't need to group this, just remove the SUM:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(([VGW03] / [BMSCH]) * [GMNGA]) /60 as [Line Hours]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You use group by when you want to aggregate something on one or more dimensions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;edit: missed this part: "&lt;SPAN&gt;It will also load with that line but without SUM in front of it (but the value of [Line Hours] is then not correct)."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Should work correct, what result do you get?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Feb 2023 13:39:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/SUM-within-Loadscript-Invalid-Expression/m-p/2034447#M85246</guid>
      <dc:creator>jbhappysocks</dc:creator>
      <dc:date>2023-02-06T13:39:41Z</dc:date>
    </item>
  </channel>
</rss>

