<?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: Validation Checks in Load Script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Validation-Checks-in-Load-Script/m-p/1736171#M622151</link>
    <description>&lt;P&gt;You can see attached code below :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Aug 2020 10:08:02 GMT</pubDate>
    <dc:creator>alkoni</dc:creator>
    <dc:date>2020-08-16T10:08:02Z</dc:date>
    <item>
      <title>Validation Checks in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/Validation-Checks-in-Load-Script/m-p/1237621#M622148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi There,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to put some validation checks in my Qlik Sense Load Script. The idea is to be able to compare distinct value counts between a dimension from a monthly file and a mapping table (which is maintained manually). For example:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Fact File:&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="115.545454" style="border: 1px solid #000000; width: 371.545px; height: 111.545px;" width="369.545454"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Sector&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Revenue&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Blue&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Red&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;150&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Orange&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;220&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;White&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;120&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Mapping Table:&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="92.545454" style="border: 1px solid #000000; width: 371.545px; height: 50.5455px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;SectorMap&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Zone&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Blue&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Zone 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Red&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Zone 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Orange&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Zone 2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the above example, the mapping file is missing an entry for "White" sector, and hence would show a blank / Null in "Zone"&lt;/P&gt;&lt;P&gt;I want to compare the distinct counts in both these file during the loading process, and throw an error is there is a count mismatch.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Let vFactCount = Count (Distinct Sector);&lt;/P&gt;&lt;P&gt;Let vMappingCount = Count (Distinct SectorMap);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If '$(&lt;SPAN style="font-size: 13.3333px;"&gt;vFactCount &lt;/SPAN&gt;)' &amp;lt;&amp;gt; '$(&lt;SPAN style="font-size: 13.3333px;"&gt;vMappingCount &lt;/SPAN&gt;)' then&lt;/P&gt;&lt;P&gt;Trace 'ERROR: Count Mismatch:&amp;nbsp; Fact Count - ' &amp;amp; '$(&lt;SPAN style="font-size: 13.3333px;"&gt;vFactCount &lt;/SPAN&gt;)' &amp;amp; 'and Mapping Count - ' &amp;amp; '$(&lt;SPAN style="font-size: 13.3333px;"&gt;vMappingCount &lt;/SPAN&gt;)' ;&lt;/P&gt;&lt;P&gt;Else&lt;/P&gt;&lt;P&gt;Trace "Validation Check Complete";&lt;/P&gt;&lt;P&gt;End if&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this does not work as intended, It does not capture any count values and gives the output &lt;SPAN style="font-size: 13.3333px;"&gt;"Validation Check Complete".&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jan 2017 19:43:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Validation-Checks-in-Load-Script/m-p/1237621#M622148</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-01-25T19:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Validation Checks in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/Validation-Checks-in-Load-Script/m-p/1237622#M622149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to use peek first to get value into variables. Then compare variable in if&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;TableB:&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Count&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;DISTINCT&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Sector&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;fc&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Resident&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; FactFileTable;&lt;BR /&gt; &lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="; color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG&gt;Let&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #808080; font-size: 8pt;"&gt;&lt;EM&gt;vFactCount&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Peek&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;('fc',0,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;TableB&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Please do the same for both your variables and then compare. AS of now both having NULL I guess as per your current script.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jan 2017 20:02:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Validation-Checks-in-Load-Script/m-p/1237622#M622149</guid>
      <dc:creator>girirajsinh</dc:creator>
      <dc:date>2017-01-25T20:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Validation Checks in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/Validation-Checks-in-Load-Script/m-p/1237623#M622150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you could use the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vFactCount = fieldvaluecount('Sector');&lt;/P&gt;&lt;P&gt;Let vMappingCount = fieldvaluecount('SectorMap');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If '$(&lt;SPAN style="font-size: 13.3333px;"&gt;vFactCount &lt;/SPAN&gt;)' &amp;lt;&amp;gt; '$(&lt;SPAN style="font-size: 13.3333px;"&gt;vMappingCount &lt;/SPAN&gt;)' then&lt;/P&gt;&lt;P&gt;Trace 'ERROR: Count Mismatch:&amp;nbsp; Fact Count - ' &amp;amp; '$(&lt;SPAN style="font-size: 13.3333px;"&gt;vFactCount &lt;/SPAN&gt;)' &amp;amp; 'and Mapping Count - ' &amp;amp; '$(&lt;SPAN style="font-size: 13.3333px;"&gt;vMappingCount &lt;/SPAN&gt;)' ;&lt;/P&gt;&lt;P&gt;Else&lt;/P&gt;&lt;P&gt;Trace "Validation Check Complete";&lt;/P&gt;&lt;P&gt;End if&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;whereby you will need to load the mapping-data twice - one time normal to be able to access the table/fields and then a second time as mapping-table which is in general unaccessable unless by using mapping functions/statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jan 2017 08:54:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Validation-Checks-in-Load-Script/m-p/1237623#M622150</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2017-01-26T08:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Validation Checks in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/Validation-Checks-in-Load-Script/m-p/1736171#M622151</link>
      <description>&lt;P&gt;You can see attached code below :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Aug 2020 10:08:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Validation-Checks-in-Load-Script/m-p/1736171#M622151</guid>
      <dc:creator>alkoni</dc:creator>
      <dc:date>2020-08-16T10:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Validation Checks in Load Script</title>
      <link>https://community.qlik.com/t5/QlikView/Validation-Checks-in-Load-Script/m-p/1736172#M622152</link>
      <description>&lt;P&gt;FactFile:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;[Sector],&lt;/P&gt;&lt;P&gt;[Revenue]&lt;/P&gt;&lt;P&gt;FROM [lib://AttachedFiles/FactFile.xlsx]&lt;/P&gt;&lt;P&gt;(ooxml, embedded labels, table is Sheet1);&lt;/P&gt;&lt;P&gt;MappingTable:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;[SectorMap],&lt;/P&gt;&lt;P&gt;[Zone]&lt;/P&gt;&lt;P&gt;FROM [lib://AttachedFiles/MappingTable.xlsx]&lt;/P&gt;&lt;P&gt;(ooxml, embedded labels, table is Sheet1);&lt;/P&gt;&lt;P&gt;TableB:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;Count(DISTINCT Sector) as ff&lt;/P&gt;&lt;P&gt;Resident FactFile;&lt;/P&gt;&lt;P&gt;Let vFactCount = Peek('ff',0,TableB);&lt;/P&gt;&lt;P&gt;TableC:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;Count (Distinct SectorMap) as mf&lt;/P&gt;&lt;P&gt;Resident MappingTable;&lt;/P&gt;&lt;P&gt;Let vMappingCount = Peek('mf',0,TableC);&lt;/P&gt;&lt;P&gt;If $(vFactCount) &amp;lt;&amp;gt; $(vMappingCount) then&lt;/P&gt;&lt;P&gt;Trace 'ERROR: Count Mismatch: Fact Count': $(vFactCount)&amp;nbsp; 'Mapping Count': $(vMappingCount)&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;Elseif&lt;/P&gt;&lt;P&gt;Trace 'Validation Check Complete';&lt;/P&gt;&lt;P&gt;Endif&lt;/P&gt;&lt;P&gt;Exit Script;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Aug 2020 10:11:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Validation-Checks-in-Load-Script/m-p/1736172#M622152</guid>
      <dc:creator>alkoni</dc:creator>
      <dc:date>2020-08-16T10:11:57Z</dc:date>
    </item>
  </channel>
</rss>

