<?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: Cumulation Month and Year in the Script in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1865567#M71436</link>
    <description>&lt;P&gt;Hi, Yes, if renamed it should be Peek('Year_C').&lt;/P&gt;
&lt;P&gt;It the value it's a lot higher maybe it's caused because there are more than one row for each Year-Month and the expression is doing a Sum() of different accumulated values.&lt;/P&gt;
&lt;P&gt;what the field Acum_AEC does is: if the row previously loaded has the same year than this one, add the row AEC the the value already accumualdted in Acum_AEC; and this Acum_AEC will be used in the next row if still is in the same year.&lt;/P&gt;
&lt;P&gt;You can add a RowNo() as NoOfRow field in script, and add it to the table to check what is happening row by row.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Dec 2021 14:52:30 GMT</pubDate>
    <dc:creator>rubenmarin</dc:creator>
    <dc:date>2021-12-01T14:52:30Z</dc:date>
    <item>
      <title>Cumulation Month and Year in the Script</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1863976#M71315</link>
      <description>&lt;P&gt;Dear Qlik users,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create a table of cumulative values in the script.&lt;/P&gt;
&lt;P&gt;Contrary to all the post of this subject in the community, I don't have a specific fields of dates but rather 2 fields : the month and the year in the script.&lt;/P&gt;
&lt;P&gt;I have tried a few different ways to design such a tables without any success.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="load pb script.PNG" style="width: 737px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/67494iE6520E9290D49AA1/image-size/large?v=v2&amp;amp;px=999" role="button" title="load pb script.PNG" alt="load pb script.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As you can see, the value field is EAC.&lt;/P&gt;
&lt;P&gt;I am consolidating the values per month and per year in one sheet.&lt;/P&gt;
&lt;P&gt;Below, the EAC21 field is defined like such&lt;/P&gt;
&lt;P&gt;sum({$&amp;lt;[Cost Baseline Version]={"RF*"},[Monthly Cost Destination]={'CAPEX'}&amp;gt;} EAC)/1000000&lt;/P&gt;
&lt;P&gt;and &lt;STRONG&gt;I want to edit the script so that the very same definition would do "Cumulated EAC21"&lt;/STRONG&gt;&amp;nbsp; :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="table cumul.PNG" style="width: 565px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/67495iDD3AB726904BCE6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="table cumul.PNG" alt="table cumul.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am quite lost and I really have no idea as of what to try next.&lt;/P&gt;
&lt;P&gt;Thank you very much for your help !&lt;/P&gt;</description>
      <pubDate>Fri, 26 Nov 2021 14:00:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1863976#M71315</guid>
      <dc:creator>abonnery</dc:creator>
      <dc:date>2021-11-26T14:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulation Month and Year in the Script</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1864094#M71324</link>
      <description>&lt;P&gt;Hi, you can do a load&amp;nbsp; order by year and month, and use pek to check where the year changes and start again.&lt;/P&gt;
&lt;P&gt;First note that if you have many diffretn rows for each year-month you will need and extra table to store accumulations, in any case an script like this would do the accumulation in script:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;tmpInitialData:
//Load excel data

FinalTable:
LOAD
  Year &amp;amp;'_'&amp;amp; Month as AccumKey, // Only if you neeed and additional table to store accumulation, this woud be the key to realte to the main table
  Year,
  EAC,
  IF(peek(Year)=Year
    ,RangeSum(EAC, Peek(Acum_EAC))
    ,EAC)  as Acum_EAC
Resident tmpInitialData
Where [Cost Baseline Version] like "RF* AND Monthly... //Only if needed
Order By Year, Month;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Nov 2021 08:12:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1864094#M71324</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2021-11-27T08:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulation Month and Year in the Script</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1864524#M71360</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your answer.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will be concatenating this table with another so I need to keep this exact same fields and will be modifying only the Cumulated Values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I inspired from your script (The order by was not recognized in the data load editor), I have enclosed the one I loaded in Qlik Sense below. I need to keep both Year and Month fields as well as the other taggs (customer, etc).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The cumulation didn't work. It shows normal non cumulated values. I believe this is due to the 1st condition of the if statement.&lt;/P&gt;
&lt;P&gt;Do you know how I can modify this script so that it works ?&lt;/P&gt;
&lt;P&gt;Thank you for your help.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Cum_Table:


LOAD
    '&amp;lt;NoData&amp;gt;' AS "Date of forecast_C" ,
     "Project Name",
    "Cost PLW Curve Name" AS "Cost PLW Curve Name_C",
    "Customer Base entity" AS "Customer Base entity_C",
    
    "Customer Name" AS  "Customer Name_C",
    
    "Year" AS "Year_C",
    "Month" AS "Month_C",
    'Cumulated_'&amp;amp;"Cost Baseline Version" AS "Cost Baseline Version_C",
    "Cost Origin" AS "Cost Origin_C",
    "Monthly Cost Destination" AS "Monthly Cost Destination_C",
    "Monthly Cost Origin" AS "Monthly Cost Origin_C",
     IF(peek(Year)=Year,RangeSum(EAC, Peek("Month"&amp;amp;"-"&amp;amp;"Year")),EAC)  as Acum_EAC
     
    FROM [lib://Tables for Qliksense.xlsx]
(ooxml, embedded labels, header is 1 lines, table is Cost);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 15:35:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1864524#M71360</guid>
      <dc:creator>abonnery</dc:creator>
      <dc:date>2021-11-29T15:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulation Month and Year in the Script</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1864740#M71377</link>
      <description>&lt;P&gt;Hi, if you rename Year as Year_C, when you access the rpevious row it is stored as Year_C, no Year, so Peek() needs to query for this field name:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;IF(peek(Year_C)=Year,RangeSum(EAC, Peek("Month"&amp;amp;"-"&amp;amp;"Year")),EAC)  as Acum_EAC&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 07:16:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1864740#M71377</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2021-11-30T07:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulation Month and Year in the Script</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1864799#M71380</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I changed it (script below) and it's still not working. The cumulation doesn't work and the app tells me 'internal error' every 2 seconds.&lt;/P&gt;
&lt;P&gt;The 3rd column is the Acum field from this script and the 4th is what I would like it to be.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="abonnery_0-1638265889405.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/67609i61D71D0C0844A8CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="abonnery_0-1638265889405.png" alt="abonnery_0-1638265889405.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Cumulated_Table:


LOAD
    '&amp;lt;NoData&amp;gt;' AS "Date of forecast_C" ,
     "Project Name",
    "Cost PLW Curve Name" AS "Cost PLW Curve Name_C",
    "Customer Base entity" AS "Customer Base entity_C",
    
    "Customer Name" AS  "Customer Name_C",
    
    "Year" AS "Year_C",
    "Month" AS "Month_C",
    'Cumulated_'&amp;amp;"Cost Baseline Version" AS "Cost Baseline Version_C",
    "Cost Origin" AS "Cost Origin_C",
    "Monthly Cost Destination" AS "Monthly Cost Destination_C",
    "Monthly Cost Origin" AS "Monthly Cost Origin_C",
     IF(peek(Year_C)=Year,RangeSum(EAC, Peek("Month"&amp;amp;'-'&amp;amp;"Year")),EAC) as Acum_EAC 
     
    FROM [lib://Tables for Qliksense.xlsx]
(ooxml, embedded labels, header is 1 lines, table is Cost);
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 09:53:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1864799#M71380</guid>
      <dc:creator>abonnery</dc:creator>
      <dc:date>2021-11-30T09:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulation Month and Year in the Script</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1865046#M71399</link>
      <description>&lt;P&gt;Hi, I'm my initial post I used an initial table to laod excel file, and then another table to load using order by, this code it's not doing that, if excel is sorted it may work but I would do the double step to ensure the load order of the rows.&lt;/P&gt;
&lt;P&gt;Also I don't understan this sentence: IF(peek(Year)=Year,RangeSum(EAC, &lt;FONT color="#FF0000"&gt;Peek("Month"&amp;amp;"-"&amp;amp;"Year"&lt;/FONT&gt;)),EAC) as Acum_EAC&lt;/P&gt;
&lt;P&gt;Mine was: IF(peek(Year)=Year,RangeSum(EAC, Peek(Acum_EAC)),EAC) as Acum_EAC&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 16:42:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1865046#M71399</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2021-11-30T16:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulation Month and Year in the Script</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1865391#M71425</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have tried the line :&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;IF(peek(Year)=Year,RangeSum(EAC, Peek(Acum_EAC)),EAC) as Acum_EAC&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;and the cumulation didn't work (values not cumulated)&lt;/P&gt;
&lt;P&gt;as well as the statement :&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;IF(peek("Year_C")=Year,RangeSum(EAC, Peek(Acum_EAC)),EAC) as Acum_EAC&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;This time, some sort of cumulation happened but not the right one. On the left the cumulation from the script and on the right the non-cumulated values and the right cumulation (from the Accumulation of the table not from the script).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="abonnery_0-1638355667394.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/67696i2558A1AC1E74ACA7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="abonnery_0-1638355667394.png" alt="abonnery_0-1638355667394.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Do you know why the accumation from the script is not the same as the good one ? Why doesn't it start at the first value of the year (January 2021) ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 10:51:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1865391#M71425</guid>
      <dc:creator>abonnery</dc:creator>
      <dc:date>2021-12-01T10:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulation Month and Year in the Script</title>
      <link>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1865567#M71436</link>
      <description>&lt;P&gt;Hi, Yes, if renamed it should be Peek('Year_C').&lt;/P&gt;
&lt;P&gt;It the value it's a lot higher maybe it's caused because there are more than one row for each Year-Month and the expression is doing a Sum() of different accumulated values.&lt;/P&gt;
&lt;P&gt;what the field Acum_AEC does is: if the row previously loaded has the same year than this one, add the row AEC the the value already accumualdted in Acum_AEC; and this Acum_AEC will be used in the next row if still is in the same year.&lt;/P&gt;
&lt;P&gt;You can add a RowNo() as NoOfRow field in script, and add it to the table to check what is happening row by row.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 14:52:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Cumulation-Month-and-Year-in-the-Script/m-p/1865567#M71436</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2021-12-01T14:52:30Z</dc:date>
    </item>
  </channel>
</rss>

