Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
microwin88x
Creator III
Creator III

Solved

Hello,

I have the following table with fields PERIOD and AMOUNT:

PERIODAMOUNTACUMOP
201301448448448
201302390838419
2013034991337445,666667
2013041531490372,5
2013054601950390
2013063362286381
2013073332619374,142857
2013084293048381
2013093463394377,111111
201310223416341,6
201311113427311,545455
2013123563783315,25
201401148148148
201402184332166
201403356688229,333333
201404245933233,25
20140534967193,4
2014063241291215,166667
2014073001591227,285714
2014083321923240,375
2014092592182242,444444
2014104592641264,1
2014114813122283,818182
201412313153262,75
201501306306306
20150298404202
201503373777259
201504176953238,25
2015053201273254,6

I need to calculate the fields ACUM and OP by script where:

ACUM for 201301 is 448, ACUM for 201302 is 448+390=838, ACUM for 201303 is 448+390+499=1337

OP for 201301 is 448/01, OP for 201302 is 838/02, OP for 201303 is 1337/03

Do you know how could I do this?

Thank you!

Solved

1 Solution

Accepted Solutions
sunny_talwar

Try this:

Table:

LOAD *,

  YEAR(PERIOD) as YEAR,

  Num(Month(PERIOD)) as MONTH;

LOAD Date#(PERIOD, 'YYYYMM') as PERIOD,

    AMOUNT

FROM

[https://community.qlik.com/thread/190352]

(html, codepage is 1252, embedded labels, table is @1);

FinalTable:

LOAD *,

  ACUM/MONTH as OP;

LOAD *,

  If(YEAR = Peek('YEAR'), RangeSum(PEEK('ACUM'), AMOUNT), AMOUNT) as ACUM

Resident Table;

DROP Table Table;


Capture.PNG

View solution in original post

2 Replies
Chanty4u
MVP
MVP

hi,

RangeSum(Above(TOTAL Sum(PERIOD), 0, RowNo(TOTAL)))/sum(total AMOUNT)

or

RangeSum(Above(TOTAL Sum(PERIOD), 0, RowNo(TOTAL)))/sum(total PERIOD)

hope this helps you

thanks

suresh

sunny_talwar

Try this:

Table:

LOAD *,

  YEAR(PERIOD) as YEAR,

  Num(Month(PERIOD)) as MONTH;

LOAD Date#(PERIOD, 'YYYYMM') as PERIOD,

    AMOUNT

FROM

[https://community.qlik.com/thread/190352]

(html, codepage is 1252, embedded labels, table is @1);

FinalTable:

LOAD *,

  ACUM/MONTH as OP;

LOAD *,

  If(YEAR = Peek('YEAR'), RangeSum(PEEK('ACUM'), AMOUNT), AMOUNT) as ACUM

Resident Table;

DROP Table Table;


Capture.PNG