<?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 Creating numeric key fields to connect tables in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Creating-numeric-key-fields-to-connect-tables/m-p/355859#M706237</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to ask, could someone share some best practices how to create numeric key fields to connect tables in QlikView data model.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you load full scope of data all at once, this is not a problem - just use &lt;STRONG&gt;AUTONUMBER &lt;/STRONG&gt;function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if you load incremental data, just the &lt;STRONG&gt;AUTONUMBER &lt;/STRONG&gt;function is not enough. I came up with the conclusion, that using &lt;STRONG&gt;APPLYMAP &lt;/STRONG&gt;function is not very convienient, because it returns a argument if it does not find a corresponding record in mapping table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I came up with this approach&lt;/P&gt;&lt;P&gt;1. Maintain a table for each key which contains two fields - key field expression and row number.&lt;/P&gt;&lt;P&gt;2. Fill the table with new key field expression combinations as needed.&lt;/P&gt;&lt;P&gt;3. Load it before all transformations with &lt;STRONG&gt;LOAD AUTONUMBER(key_field, 'map_field_name') as field FROM .... (qvd).&lt;/STRONG&gt; This is needed to setup AUTONUMBER function counter&lt;/P&gt;&lt;P&gt;4. Use &lt;STRONG&gt;AUTONUMBER(key_field, 'map_field_name')&lt;/STRONG&gt; everytime you need a key value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works quite fine. But maybe there is some &lt;STRONG&gt;better &lt;/STRONG&gt;solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/cool.png" /&gt;&lt;/P&gt;&lt;P&gt;Cheers &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;Darius &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV class="mcePaste" id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;"&gt; &lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;Hello&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;I would like to ask, could someone share some best practices how to create numeric key fields to connect tables in QlikView data model.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;If you load full scope of data all at once, this is not a problem - just use AUTONUMBER function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;But if you load incremental data, just the AUTONUMBER function is not enough. I came up with the conclusion, that using APPLYMAP function is not very convenient, because it returns an argument if it does not find a corresponding record in mapping table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;Now I came up with this approach&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;1. Maintain a table for each key which contains two fields - key field expression and row number.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;2. Fill the table with new key field expression combinations as needed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;3. Load it before all transformations with LOAD AUTONUMBER(key_field, 'map_field_name') as field FROM .... (qvd). This is needed to setup AUTONUMBER function counter&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;4. Use AUTONUMBER(key_field, 'map_field_name') every time you need a key value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;This works quite fine. But maybe there is some better&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Mar 2012 12:19:03 GMT</pubDate>
    <dc:creator>d_pranskus</dc:creator>
    <dc:date>2012-03-16T12:19:03Z</dc:date>
    <item>
      <title>Creating numeric key fields to connect tables</title>
      <link>https://community.qlik.com/t5/QlikView/Creating-numeric-key-fields-to-connect-tables/m-p/355859#M706237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to ask, could someone share some best practices how to create numeric key fields to connect tables in QlikView data model.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you load full scope of data all at once, this is not a problem - just use &lt;STRONG&gt;AUTONUMBER &lt;/STRONG&gt;function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if you load incremental data, just the &lt;STRONG&gt;AUTONUMBER &lt;/STRONG&gt;function is not enough. I came up with the conclusion, that using &lt;STRONG&gt;APPLYMAP &lt;/STRONG&gt;function is not very convienient, because it returns a argument if it does not find a corresponding record in mapping table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I came up with this approach&lt;/P&gt;&lt;P&gt;1. Maintain a table for each key which contains two fields - key field expression and row number.&lt;/P&gt;&lt;P&gt;2. Fill the table with new key field expression combinations as needed.&lt;/P&gt;&lt;P&gt;3. Load it before all transformations with &lt;STRONG&gt;LOAD AUTONUMBER(key_field, 'map_field_name') as field FROM .... (qvd).&lt;/STRONG&gt; This is needed to setup AUTONUMBER function counter&lt;/P&gt;&lt;P&gt;4. Use &lt;STRONG&gt;AUTONUMBER(key_field, 'map_field_name')&lt;/STRONG&gt; everytime you need a key value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works quite fine. But maybe there is some &lt;STRONG&gt;better &lt;/STRONG&gt;solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/cool.png" /&gt;&lt;/P&gt;&lt;P&gt;Cheers &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;Darius &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV class="mcePaste" id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;"&gt; &lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;Hello&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;I would like to ask, could someone share some best practices how to create numeric key fields to connect tables in QlikView data model.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;If you load full scope of data all at once, this is not a problem - just use AUTONUMBER function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;But if you load incremental data, just the AUTONUMBER function is not enough. I came up with the conclusion, that using APPLYMAP function is not very convenient, because it returns an argument if it does not find a corresponding record in mapping table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;Now I came up with this approach&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;1. Maintain a table for each key which contains two fields - key field expression and row number.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;2. Fill the table with new key field expression combinations as needed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;3. Load it before all transformations with LOAD AUTONUMBER(key_field, 'map_field_name') as field FROM .... (qvd). This is needed to setup AUTONUMBER function counter&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;4. Use AUTONUMBER(key_field, 'map_field_name') every time you need a key value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt;This works quite fine. But maybe there is some better&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="MsoNormal"&gt;&lt;SPAN lang="EN-US" style="mso-ansi-language: EN-US;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2012 12:19:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Creating-numeric-key-fields-to-connect-tables/m-p/355859#M706237</guid>
      <dc:creator>d_pranskus</dc:creator>
      <dc:date>2012-03-16T12:19:03Z</dc:date>
    </item>
  </channel>
</rss>

