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

Logic

Hi All

Need Logic from Script:

  

MOB          Desired Output by using MOB

10               10

20               10+20=30

30               10+20+30=60

40               10+20+30+40=100

50               10+20+30+40+50=150

Regards

Aviral

1 Solution

Accepted Solutions
NareshGuntur
Partner - Specialist
Partner - Specialist

Hi Nag,

Please use the following script.

Credits to Jagan Mohan.(How can I calculate a cumulative sum in load script?)

TableName:

LOAD

    F1,

    F2,

    RangeSum(F2, Peek('CumSum')) AS CumSum;

LOAD * INLINE [

    F1, F2

    a, 100

    b, 200

    c, 300

    d, 400

];

Cheers,

Naresh

View solution in original post

14 Replies
rustyfishbones
Master II
Master II

Can you try in the script

Previous(MOB)/2 AS [New Field Requirement]

looks like this in my example

2014-04-25_1421.png

its_anandrjs

Use Previous function.

aveeeeeee7en
Specialist III
Specialist III
Author

Hi Alan, I actually want this:

MOB          Desired Output by using MOB

10               10

20               10+20=30

30               10+20+30=60

40               10+20+30+40=100

50               10+20+30+40+50=150

rustyfishbones
Master II
Master II

Yes I see, I am trying to figure it out

its_anandrjs

Provide your previous image also where you explain it will more clear.

rustyfishbones
Master II
Master II

Use this expression

RangeSum(above(sum(MOB),0,RowNo()))

rustyfishbones
Master II
Master II

you can also use

2014-04-25_1441.png

to get the running Average

hope that helps

aveeeeeee7en
Specialist III
Specialist III
Author

Thanks Alan, it is working Perfectly.

But I have used it earlier. As I said in my requirement, I need this thing from the Script not from my Chart Expression.

maxgro
MVP
MVP

a:

load

  MOB,

  alt(peek(MOBSUM),0) +MOB as MOBSUM;

load * inline [

MOB        

10         

20         

30         

40         

50    

];

EDIT

or this?

1.png

a:

load

  MOB,

  alt(peek(MOBSUM),0) +MOB as MOBSUM,

  if(rowno()=1, text(MOB), peek(MOBSUMTXT) & ' + ' & text(MOB)) as MOBSUMTXT;

load * inline [

MOB         

10          

20          

30          

40          

50     

];