<?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: Data Transformation in Qlikview script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422210#M809969</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;Thank you for your response. The first approach is simple and easy. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;However, I have to do a similar calculation for multiple cases and I might end up writing a very long piece of code to get the desired result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can explain the second method in detail, that would be very helpful. &lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shashank&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Oct 2017 23:17:57 GMT</pubDate>
    <dc:creator>s2016</dc:creator>
    <dc:date>2017-10-10T23:17:57Z</dc:date>
    <item>
      <title>Data Transformation in Qlikview script</title>
      <link>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422207#M809966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;I have a sample data set attached in the spreadsheet. The two sheets have "Input" and "Expected Output" data. &lt;/P&gt;&lt;P&gt;The Input data has 48 records each &lt;SPAN style="font-size: 13.3333px;"&gt;(one for each 'ts') &lt;/SPAN&gt;for 3 different CG_Name's (BEL, BGS and TW). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;For each 'ts' value, I want to create a new CG_Name = 'NAT' and calculate throughput_in, volume_in, SIOs etc., as the difference of value between the 3 CG_Name's as below.&amp;nbsp; &lt;/P&gt;&lt;P&gt;BGS &lt;SPAN style="font-size: 13.3333px;"&gt;throughput_in &lt;/SPAN&gt;- &lt;SPAN style="font-size: 13.3333px;"&gt;BEL &lt;SPAN style="font-size: 13.3333px;"&gt;throughput_in &lt;/SPAN&gt; - &lt;SPAN style="font-size: 13.3333px;"&gt;TW &lt;SPAN style="font-size: 13.3333px;"&gt;throughput_in&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;. &lt;/P&gt;&lt;P&gt;(- means subtraction).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would really appreciate if you can help me with the approach / write the code for this.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Please note that the original data source is a database and this calculation needs to be done in Qlikview backend. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Shashank &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422207#M809966</guid>
      <dc:creator>s2016</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transformation in Qlikview script</title>
      <link>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422208#M809967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly find the attached Application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe some experts will help you in a better method than me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="179095" alt="277426.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/179095_277426.PNG" style="height: 415px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Oct 2017 07:06:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422208#M809967</guid>
      <dc:creator>mdmukramali</dc:creator>
      <dc:date>2017-10-10T07:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transformation in Qlikview script</title>
      <link>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422209#M809968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would denormalize the database:&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;ts, est_date, throughput_in AS BEL_throughput_in, .... FROM .... WHERE CG_Name = 'BEL';&lt;/P&gt;&lt;P&gt;JOIN (Data) LOAD&lt;/P&gt;&lt;P&gt;ts, est_date, throughput_in AS BGS_throughput_in, .... FROM .... WHERE CG_Name = 'BGS';&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Doing so, you would have all values in one line in the database, where it will be easy to calculate with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively you may load the data sorted by ts and CG_Name and then do the calculation on the last record (e.g. TW):&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;*,&lt;/P&gt;&lt;P&gt;IF (CG_Name = 'TW', PREVIOUS(throughput_in) - PREVIOUS(PREVIOUS(throughput_in)) - throughput_in) AS NAT_throughput,&lt;/P&gt;&lt;P&gt;.....;&lt;/P&gt;&lt;P&gt;LOAD * FROM ..... ORDER BY ts, CG_Name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: apostrophs removed (PREVIOUS does not require. PEEK might be used, but then aprostrophs are needed)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Oct 2017 07:27:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422209#M809968</guid>
      <dc:creator>prieper</dc:creator>
      <dc:date>2017-10-10T07:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transformation in Qlikview script</title>
      <link>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422210#M809969</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;Thank you for your response. The first approach is simple and easy. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;However, I have to do a similar calculation for multiple cases and I might end up writing a very long piece of code to get the desired result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can explain the second method in detail, that would be very helpful. &lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shashank&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Oct 2017 23:17:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422210#M809969</guid>
      <dc:creator>s2016</dc:creator>
      <dc:date>2017-10-10T23:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transformation in Qlikview script</title>
      <link>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422211#M809970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Data:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;LOAD CG_Name,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; est_date,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; week_start,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; throughput_in,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; throughput_out,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; volume_in,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; volume_out,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SIOs&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;FROM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;SampleData.xlsx&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;(ooxml, embedded labels, table is Input);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;NATData:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'NAT' as CG_Name,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(if(CG_Name='BGS',throughput_in, -throughput_in)) as throughput_in,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(if(CG_Name='BGS',throughput_out, -throughput_out)) as throughput_out,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(if(CG_Name='BGS',volume_in, -volume_in)) as volume_in,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(if(CG_Name='BGS',volume_out, -volume_out)) as volume_out,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(if(CG_Name='BGS',SIOs, -throughput_out)) as SIOs&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Resident Data&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Group By ts&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// Grab the other Dimension values if desired&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;JOIN (NATData)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; est_date,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; week_start&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Resident Data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;DROP TABLE Data; &lt;/SPAN&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://masterssummit.com" rel="nofollow" target="_blank"&gt;http://masterssummit.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://qlikviewcookbook.com" rel="nofollow" target="_blank"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Oct 2017 01:15:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422211#M809970</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2017-10-11T01:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transformation in Qlikview script</title>
      <link>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422212#M809971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you everyone.&lt;/P&gt;&lt;P&gt;All the answers are correct, but I have marked Rob's answer as the Correct Answer because of ease of writing the code and also having to avoid Joins. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Oct 2017 03:33:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422212#M809971</guid>
      <dc:creator>s2016</dc:creator>
      <dc:date>2017-10-11T03:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: Data Transformation in Qlikview script</title>
      <link>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422213#M809972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As a refinement, you could do this in a single step&amp;nbsp; I did it in stages because I was validating as I went.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;NATData:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;'NAT' as CG_Name,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;ts,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sum(if(CG_Name='BGS',throughput_in, -throughput_in)) as throughput_in,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sum(if(CG_Name='BGS',throughput_out, -throughput_out)) as throughput_out,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sum(if(CG_Name='BGS',volume_in, -volume_in)) as volume_in,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sum(if(CG_Name='BGS',volume_out, -volume_out)) as volume_out,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sum(if(CG_Name='BGS',SIOs, -throughput_out)) as SIOs&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;FROM&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;SampleData.xlsx&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;(ooxml, embedded labels, table is Input)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Group By ts, est_date,&amp;nbsp; week_start&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://masterssummit.com" rel="nofollow" target="_blank"&gt;http://masterssummit.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://qlikviewcookbook.com" rel="nofollow" target="_blank"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Oct 2017 03:58:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Data-Transformation-in-Qlikview-script/m-p/1422213#M809972</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2017-10-11T03:58:07Z</dc:date>
    </item>
  </channel>
</rss>

