Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Cumulative sum per Week, Country and Priority

Hi Everyone,

Captura1.PNG

I want to calculate stock per week, country and Priority. So when i usee it in a chart with the dimension Week and the field Stock. It shows the accumulate of the stock.

Thanks for your time,

Javier

CountStock:

Load *,

WeekTemp1 &'|'& [CountryStart] &'|'& [PrioStart] as K_WStart_Country_Prio,  

   If(AutoNumberHash128(WeekTemp1,CountryStart,PrioStart)=Previous((AutoNumberHash128(Peek('WeekTemp1'), Peek('CountryStart'),Peek('PrioStart')))),

  

  Peek([Cumulative qty])+Stocksinacumular,Stocksinacumular) as Stock2 ,

  

 

  If(AutoNumberHash128(WeekTemp1,CountryStart,PrioStart)=Previous(AutoNumberHash128(WeekTemp1,CountryStart,PrioStart)),

     

 

   RangeSum(Stocksinacumular, Peek('Stock3'))) as Stock3

  

Resident CountStockTemp

order by WeekTemp1,CountryStart,PrioStart ;

drop table CountStockTemp,OrderStockTemp;

Community Browser