<?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: Check Dimension Totals Before Loading in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Check-Dimension-Totals-Before-Loading/m-p/2460409#M98795</link>
    <description>&lt;P&gt;Hi, Count works on charts, in script it only works using it on a load sentence of a table, you can crete a temporary table to do the counts and use peek to retieve the values, like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Values:
LOAD...
Right Keep (Values)
LOAD...
FROM [*Excel File*]:

tmpCount:
LOAD 
  Count(ItemNumber) as NumberCount,
  Count(Distinct ItemNumber) as DistinctNumberCount
Resident Values;

LET vNumberCount = Peek('NumberCount',0);
LET vDistinctNumberCount = Peek('DistinctNumberCount',0);

DROP Table tmpCount;

If $(vNumberCount)...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if the final table should end with a row for each different ItemNumber you can just do the load of the data and then do the comparison as:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;IF NoOfRows('Values')&amp;lt;&amp;gt;FieldValueCount('ItemNumber') THEN
  TRACE ...
END IF&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 08 Jun 2024 05:56:41 GMT</pubDate>
    <dc:creator>rubenmarin</dc:creator>
    <dc:date>2024-06-08T05:56:41Z</dc:date>
    <item>
      <title>Check Dimension Totals Before Loading</title>
      <link>https://community.qlik.com/t5/App-Development/Check-Dimension-Totals-Before-Loading/m-p/2460396#M98793</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm working on a load script for a new app and want to validate that I don't have duplicate Item numbers before loading. If there are duplicates, I want to stop loading.&amp;nbsp; My code is not working, but I'm not sure why. If I look at the variables in a sheet, there is a value, but not when I try to print them using Trace, even when it's outside of the IF statement. .&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Values:&lt;/P&gt;
&lt;P&gt;LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ItemNumber&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Date,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Price&lt;/P&gt;
&lt;P&gt;FROM [*QVD File*]&lt;/P&gt;
&lt;P&gt;WHERE&lt;/P&gt;
&lt;P&gt;year(Date) &amp;gt;= year(AddYears(Today(),-1));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Right keep(Values)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NAME as ItemNumber,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Target&lt;/P&gt;
&lt;P&gt;Description&lt;/P&gt;
&lt;P&gt;Color&lt;/P&gt;
&lt;P&gt;Size&lt;/P&gt;
&lt;P&gt;Status&lt;/P&gt;
&lt;P&gt;FROM [*Excel File*]&lt;/P&gt;
&lt;P&gt;Let vDistinctNumberCount = Count(distinct TAGNAME);&lt;BR /&gt;Let vNumberCount = Count(TAGNAME);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If $(vNumberCount) &amp;lt;&amp;gt; $(vDistinctNumberCount) then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TRACE "*******Error Total ItemNumber count &amp;gt; Distinct ItemNumber count";&lt;/P&gt;
&lt;P&gt;End If;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 21:43:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Check-Dimension-Totals-Before-Loading/m-p/2460396#M98793</guid>
      <dc:creator>Lena4</dc:creator>
      <dc:date>2024-06-07T21:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Check Dimension Totals Before Loading</title>
      <link>https://community.qlik.com/t5/App-Development/Check-Dimension-Totals-Before-Loading/m-p/2460409#M98795</link>
      <description>&lt;P&gt;Hi, Count works on charts, in script it only works using it on a load sentence of a table, you can crete a temporary table to do the counts and use peek to retieve the values, like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Values:
LOAD...
Right Keep (Values)
LOAD...
FROM [*Excel File*]:

tmpCount:
LOAD 
  Count(ItemNumber) as NumberCount,
  Count(Distinct ItemNumber) as DistinctNumberCount
Resident Values;

LET vNumberCount = Peek('NumberCount',0);
LET vDistinctNumberCount = Peek('DistinctNumberCount',0);

DROP Table tmpCount;

If $(vNumberCount)...&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if the final table should end with a row for each different ItemNumber you can just do the load of the data and then do the comparison as:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;IF NoOfRows('Values')&amp;lt;&amp;gt;FieldValueCount('ItemNumber') THEN
  TRACE ...
END IF&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 08 Jun 2024 05:56:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Check-Dimension-Totals-Before-Loading/m-p/2460409#M98795</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2024-06-08T05:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Check Dimension Totals Before Loading</title>
      <link>https://community.qlik.com/t5/App-Development/Check-Dimension-Totals-Before-Loading/m-p/2460888#M98835</link>
      <description>&lt;P&gt;Thanks for taking a look at this. I tried both options and haven't been able to get the trace to work, although it seems that it should.&lt;/P&gt;
&lt;P&gt;I found a resource that suggested using an error message in brackets to stop the load. So, the code below works but I'm getting an error symbol before I even start running.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lena4_0-1718037218409.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/167658i85E5E2FC25B61C30/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Lena4_0-1718037218409.png" alt="Lena4_0-1718037218409.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;IF NoOfRows('Values') &amp;lt;&amp;gt; FieldValueCount('ItemNumber')THEN&lt;BR /&gt;[Error: ***There are duplicate values in the table****];&lt;BR /&gt;End If&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a better way to accomplish what I'm trying to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2024 16:39:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Check-Dimension-Totals-Before-Loading/m-p/2460888#M98835</guid>
      <dc:creator>Lena4</dc:creator>
      <dc:date>2024-06-10T16:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Check Dimension Totals Before Loading</title>
      <link>https://community.qlik.com/t5/App-Development/Check-Dimension-Totals-Before-Loading/m-p/2461047#M98841</link>
      <description>&lt;P&gt;Hi, that error symbols is shown when there is a syntax error, and the solution applied is to create a syntax error, so it's normal it detects that as an errror, you should be able to execute the script anyway, but instead of finishing the reload it will thrown an error when it enters the 'IF'&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 06:58:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Check-Dimension-Totals-Before-Loading/m-p/2461047#M98841</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2024-06-11T06:58:48Z</dc:date>
    </item>
  </channel>
</rss>

