Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Accumulation on scripting

Hi ALL,

Please help me regarding the following requirement which I want to achieve through script

Please find the attched file for the dummy data.

When I click on Year 2011 and Month Jan ... I want the data for Jan 2011

when I select Month Feb... I want data for Jan & Feb... like wise for Mar.. I want data for jan, feb & Mar.. and so on.

Same I want for the year 2012 also.

2 Replies
thkarner
Partner - Creator III
Partner - Creator III

Try this (to be modified for your situation)

// assumption: data is on level of %CATEG1_KEY, %CATEG2_KEY, Year, Month

LOAD

  *,

  If(Year = Peek('Year', -1) AND // if year of current record = year of pevious record and

    %CATEG1_KEY = Peek('%CATEG1_KEY', -1) AND // if same %CATEG1_KEY as previous record and

      %CATEG2_KEY = Peek('%CATEG2_KEY', -1), // if same %CATEG2_KEY as previous record

  RangeSum(Peek('Sales_Acc', -1), Sales), // previous month + current month

  RangeSum(Sales)) // use only first month of new year

  AS Sales_Acc

Resident Sales

ORDER BY %CATEG1_KEY, %CATEG2_KEY, Year, Month; // order records by all categories (%CATEG1_KEY, %CATEG1_KEY), Year and Month to use peek function for accumulation


If this helps you please mark it as helpful or correct.

Thomas


spividori
Specialist
Specialist

Hi.

See the example attaching here.

Regards.