<?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: Checksum in load script (sum all in two tables - fail when diff) in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Checksum-in-load-script-sum-all-in-two-tables-fail-when-diff/m-p/2017619#M84030</link>
    <description>&lt;P&gt;Thanks for your suggestion.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is how i ended up solving it:&lt;/P&gt;
&lt;P&gt;A) Creating a SUB&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUB CheckDiff (vRowTable)
	Let vNowRows = NoOfRows('$(vRowTable)');
    Let vDiff = vNowRows-vStartRows;
    TRACE -------------- 
    		You started with $(vStartRows) 
            .       Now you have $(vNowRows) 
            Diff is $(vDiff);
            
            
    if vDiff = 0 then
		Trace Everything is fine ;
	else
		Trace --------------  Mismatch aborting script --------------;
		Load [Aborting because the table has been duplicated] ;
	end if        

End SUB;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;B) Running this every time I manipulate the table , to check that nothing has duplicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Let vStartRows = NoOfRows('MyTable');  //At first load

Call  CheckDiff('MyTable');            //Every time I want to check consistency&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree that reducing risk of duplicates is a good thing, but verification still gives me comfort. I wear safety belt although my main priority is not to crash in the first place.&amp;nbsp; And I have experienced duplicates even when using mapping.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To Qlik I'll just mention that it's a mystery to me why there is no way of executing a load gracefully. Having to do this by making a deliberate mistake hurts my feelings. Also it makes it more difficult to give an explanation within the error itself when this is triggered.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 17 Dec 2022 10:04:28 GMT</pubDate>
    <dc:creator>oddgeir</dc:creator>
    <dc:date>2022-12-17T10:04:28Z</dc:date>
    <item>
      <title>Checksum in load script (sum all in two tables - fail when diff)</title>
      <link>https://community.qlik.com/t5/App-Development/Checksum-in-load-script-sum-all-in-two-tables-fail-when-diff/m-p/2009393#M83482</link>
      <description>&lt;P&gt;What is the best way to introduce a checksum in my load script, and fail when this is not as expected.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Until now I have used a "KPI" chart in my application, where if(sum(facts)-sum(reference)=0,'OK','Diff') However I would prefer my script to fail before saving a new version if the checksum is wrong.&amp;nbsp; Both to be notified immediately of errors when working on an application but also to ensure end users keep last good load if this happens due to poor data quality in production.&amp;nbsp; (Typically this happens with joins where something is expected to be unique which suddenly isn't)&lt;/P&gt;
&lt;P&gt;Here's an example where the last piece is for explanation and not expected to work.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Reference:
Load * Inline [
CatREF,ValueREF
a	,	1	
b	,	2	
c	,	3	
];

Facts:
Load 
		CatREF as Cat
	,	ValueREF as Value

Resident Reference;

//&amp;lt;--- adding stuff to the Facts table which may duplicate content by accident--&amp;gt;


if
        sum(Value)-sum(ValueREF)=0
    then 
        Trace Checksum OK  &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; ;
    Else
        Trace Checksum Failed;
        Exit Script;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Nov 2022 13:19:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Checksum-in-load-script-sum-all-in-two-tables-fail-when-diff/m-p/2009393#M83482</guid>
      <dc:creator>oddgeir</dc:creator>
      <dc:date>2022-11-26T13:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Checksum in load script (sum all in two tables - fail when diff)</title>
      <link>https://community.qlik.com/t5/App-Development/Checksum-in-load-script-sum-all-in-two-tables-fail-when-diff/m-p/2009730#M83509</link>
      <description>&lt;P&gt;For this you will need two extra loads, like:&lt;/P&gt;
&lt;P&gt;tx: load sum(Field) as ReferenceX resident X;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;ty: load sum(Field) as ReferenceY resident Y;&lt;/P&gt;
&lt;P&gt;if sign(fieldvalue('ReferenceX', 1) -&amp;nbsp;fieldvalue('ReferenceY', 1)) then&lt;BR /&gt;&amp;nbsp; &amp;nbsp;error ...&lt;BR /&gt;end if&lt;/P&gt;
&lt;P&gt;But just with this you won't know what your error is and what has caused it. You may get some more information if you would store this information before you break the script-execution.&lt;/P&gt;
&lt;P&gt;Personally, I would tend to avoid the mentioned risk by replacing the join-measures with mappings.&lt;/P&gt;
&lt;P&gt;- Marcus&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 12:42:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Checksum-in-load-script-sum-all-in-two-tables-fail-when-diff/m-p/2009730#M83509</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2022-11-28T12:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Checksum in load script (sum all in two tables - fail when diff)</title>
      <link>https://community.qlik.com/t5/App-Development/Checksum-in-load-script-sum-all-in-two-tables-fail-when-diff/m-p/2017619#M84030</link>
      <description>&lt;P&gt;Thanks for your suggestion.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is how i ended up solving it:&lt;/P&gt;
&lt;P&gt;A) Creating a SUB&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUB CheckDiff (vRowTable)
	Let vNowRows = NoOfRows('$(vRowTable)');
    Let vDiff = vNowRows-vStartRows;
    TRACE -------------- 
    		You started with $(vStartRows) 
            .       Now you have $(vNowRows) 
            Diff is $(vDiff);
            
            
    if vDiff = 0 then
		Trace Everything is fine ;
	else
		Trace --------------  Mismatch aborting script --------------;
		Load [Aborting because the table has been duplicated] ;
	end if        

End SUB;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;B) Running this every time I manipulate the table , to check that nothing has duplicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Let vStartRows = NoOfRows('MyTable');  //At first load

Call  CheckDiff('MyTable');            //Every time I want to check consistency&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree that reducing risk of duplicates is a good thing, but verification still gives me comfort. I wear safety belt although my main priority is not to crash in the first place.&amp;nbsp; And I have experienced duplicates even when using mapping.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To Qlik I'll just mention that it's a mystery to me why there is no way of executing a load gracefully. Having to do this by making a deliberate mistake hurts my feelings. Also it makes it more difficult to give an explanation within the error itself when this is triggered.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Dec 2022 10:04:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Checksum-in-load-script-sum-all-in-two-tables-fail-when-diff/m-p/2017619#M84030</guid>
      <dc:creator>oddgeir</dc:creator>
      <dc:date>2022-12-17T10:04:28Z</dc:date>
    </item>
  </channel>
</rss>

