<?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: Create calculated Table in Script with allocation keys in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876982#M470453</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think the T1_Key value is precalculated in the script. There is a SET statement in tab Keys, but that doesn't do anything except setting a variable to a string value. The actual calculation will be done in the Pivot Table object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the best way to approach this chalenge is to copy fields Valuehome, E14 and Docdate of all rows from PL10110_Umsatzbuchungen into a new table in your script. Then create a mapping table that maps E14 to CODE_H_CODE in Fire.xls_Budgetgruppen. Now add CODE_H_CODE to your new internal table. You may have to drop all rows that have no mapping, but that depends on which transactions should be included in your table.&lt;/P&gt;&lt;P&gt;Then perform a RESIDENT LOAD of Sum(Valuehome) with a GROUP BY on CODE_H_CODE and your preferred translation of Docdate (MonthYear or something).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next calculate a variable that sums the value of Valuehome in all rows. Call it vTotalSum.&lt;/P&gt;&lt;P&gt;Reload your new table and add ValueHome / vTotalSum as T1_Key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this something you can work on? If not, just ask. I don't have enough information (or data, or time) to do it myself in your document, but it doesn't look that difficult.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 May 2015 10:54:50 GMT</pubDate>
    <dc:creator>Peter_Cammaert</dc:creator>
    <dc:date>2015-05-18T10:54:50Z</dc:date>
    <item>
      <title>Create calculated Table in Script with allocation keys</title>
      <link>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876978#M470449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Morning everybody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a question regarding the creation of a table in the script, from which one field is calucalted.&lt;/P&gt;&lt;P&gt;A join to the existing table would not be good.&lt;/P&gt;&lt;P&gt;We have eight different keys and for every key we Need a table or one Table with all keys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I.e.&lt;/P&gt;&lt;P&gt;I have a Turnover-Table sorted by Code H (i.e. 14001,13001 and so on) --&amp;gt; see screen.&lt;/P&gt;&lt;P&gt;I have the EUR-Amount and a calculated %(T1-Key)&lt;/P&gt;&lt;P&gt;The %(T1-Key) ist calculated with in the Script&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG&gt;Set&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 8pt;"&gt;Var_T1_Key&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt; =(sum(if (Add5 = 'Gross Sales', Valuehome,0))/aggr(NODISTINCT sum(Valuehome),CODE_C_Code)); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Now the Challenge is:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I need to create a new table with the Information of the calculated keys:&lt;/P&gt;&lt;P&gt;Field 1: CODE_H_Code&lt;/P&gt;&lt;P&gt;Field 2: T1-Key&lt;/P&gt;&lt;P&gt;Field 3, Year-Period-Field (will be included later)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/86790_pastedImage_0.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 08:04:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876978#M470449</guid>
      <dc:creator />
      <dc:date>2015-05-18T08:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create calculated Table in Script with allocation keys</title>
      <link>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876979#M470450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Christian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you will have to build a FOR ... TO loop for such a thing:&lt;/P&gt;&lt;P&gt;- First you do a FIRST 1 LOAD with those three fields you want in your new table&lt;/P&gt;&lt;P&gt;- Then you do such a loop with the NoOfRows() function (rows in your original table) as the max (so it will read&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;gt;&amp;gt; FOR i = 0 TO (NoOfRows('&lt;TABLE&gt;')-1) &amp;lt;&amp;lt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- In every iteration, you can use the CONCATENATE option to append the current Code_H and T1_Key to this table&lt;/P&gt;&lt;P&gt;=&amp;gt; After the loop has completed, you should have the same nr. of rows as in your original table (plus 1, which is the empty row you have extracted for a dummy, you can throw this out now)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;/TABLE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 08:14:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876979#M470450</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2015-05-18T08:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create calculated Table in Script with allocation keys</title>
      <link>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876980#M470451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You mean, you want to write some script code that does the same thing as the P&amp;amp;L Pivot Table, right?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 08:43:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876980#M470451</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2015-05-18T08:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create calculated Table in Script with allocation keys</title>
      <link>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876981#M470452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Peter,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the T1-Key is already calculated in the Script.&lt;/P&gt;&lt;P&gt;[The PivotTable show the turnover in one column and the other column show the T1-Key.]&lt;/P&gt;&lt;P&gt;I now want to write the result of the calculation as value into a new table with the 3 columns mentioned above (CODE_H_Code, T1-Key and Year-Period).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Advantage of that would be a table with all keys for all month that I can easily use whenever I want without duplicating that Formular in every Report (Pivot).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will attach for you the file I use. The Sheet Umsatz PL10xxx (Filtered on DEDETDEC) shows the database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/86797_pastedImage_1.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe this will help to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very much thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 09:44:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876981#M470452</guid>
      <dc:creator />
      <dc:date>2015-05-18T09:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create calculated Table in Script with allocation keys</title>
      <link>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876982#M470453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think the T1_Key value is precalculated in the script. There is a SET statement in tab Keys, but that doesn't do anything except setting a variable to a string value. The actual calculation will be done in the Pivot Table object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the best way to approach this chalenge is to copy fields Valuehome, E14 and Docdate of all rows from PL10110_Umsatzbuchungen into a new table in your script. Then create a mapping table that maps E14 to CODE_H_CODE in Fire.xls_Budgetgruppen. Now add CODE_H_CODE to your new internal table. You may have to drop all rows that have no mapping, but that depends on which transactions should be included in your table.&lt;/P&gt;&lt;P&gt;Then perform a RESIDENT LOAD of Sum(Valuehome) with a GROUP BY on CODE_H_CODE and your preferred translation of Docdate (MonthYear or something).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next calculate a variable that sums the value of Valuehome in all rows. Call it vTotalSum.&lt;/P&gt;&lt;P&gt;Reload your new table and add ValueHome / vTotalSum as T1_Key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this something you can work on? If not, just ask. I don't have enough information (or data, or time) to do it myself in your document, but it doesn't look that difficult.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 10:54:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876982#M470453</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2015-05-18T10:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create calculated Table in Script with allocation keys</title>
      <link>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876983#M470454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Peter,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to think about this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the Moment it is not clear to me, why do I have to load twice.&lt;/P&gt;&lt;P&gt;At the Moment there are only Sales loaded. The costs will follow later.&lt;/P&gt;&lt;P&gt;At exactly this costs which dont have El4 have to be splitted to CODE_H_Code.&lt;/P&gt;&lt;P&gt;That is the reason why I want to calculate this keys from the one database,, without loading twice.&lt;/P&gt;&lt;P&gt;Do you think this is possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 12:03:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Create-calculated-Table-in-Script-with-allocation-keys/m-p/876983#M470454</guid>
      <dc:creator />
      <dc:date>2015-05-18T12:03:26Z</dc:date>
    </item>
  </channel>
</rss>

