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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
beck_bakytbek
Master
Master

Expression not working

Hi Folks,

i got a simple data. 

MaterialNr, Share,

A , 5.25

B,  3.26

C, 4.34

 

i am trying to create a simple cumulative value, i used 2 Options:

1. rangesum(Share, Peek('Cumul')) as Cumul

2.  if(MaterialNr= Previous(MaterialNr),Share+ Peek('Cumul'),Share) as Cumul

 

but both expressions do not work.

my output is:

 

MaterialNr, Share, Cumul

A , 5.25 ,   5.25

B,  3.26,    8.51

C, 4.34,   12.85

does anybody have any idea how to solve this issue?

Thanks a lot

Labels (1)
1 Solution

Accepted Solutions
Or
MVP
MVP

I'm afraid I have no idea what you're showing me. If you use this with the inline data (which is the data you provided), it works:

Load MaterialNr, Share, if(RecNo()=1,Share,Peek(Cumul)+Share) as Cumul INLINE [
MaterialNr, Share
A , 5.25
B, 3.26
C, 4.34
];

Or_0-1661177698690.png

 

View solution in original post

8 Replies
Or
MVP
MVP

There's a number of ways to achieve this, but I've picked the one I find easiest to read:

Load MaterialNr, Share, if(RecNo()=1,Share,Peek(Cumul)+Share) as Cumul INLINE [
MaterialNr, Share
A , 5.25
B, 3.26
C, 4.34
];

 

beck_bakytbek
Master
Master
Author

Thanks a lot for your feedback, but this expression does not work as well

Lakshminarayanan_J

@beck_bakytbek 

as suggested by @Or  , you can try it in data load editor

or 

In report , you can use the below highlighted expression,

RangeSum(Above(sum(Share),0,RowNo()))

Lakshminarayanan_J_0-1661173405733.png

 

Lakshminarayanan J
To help users find verified answers, please don't forget to use the "Accept as Solution" button
beck_bakytbek
Master
Master
Author

@Lakshminarayanan_J  thanks a lot for your feedback. i can solve this issue as expression, but i need this calculation in script .

Thanks a lot

Or
MVP
MVP

This expression works - I confirmed it by running it locally before posting. If it does not achieve what you were trying to achieve, and you want further assistance, you'll have to be more specific than "Does not work".

beck_bakytbek
Master
Master
Author

@Or  thanks a lot for your feedback:

 

i tried this:

script:

beck_bakytbek_0-1661174644069.png

 

and output does look like:

 

beck_bakytbek_1-1661174700583.png

 

 

Or
MVP
MVP

I'm afraid I have no idea what you're showing me. If you use this with the inline data (which is the data you provided), it works:

Load MaterialNr, Share, if(RecNo()=1,Share,Peek(Cumul)+Share) as Cumul INLINE [
MaterialNr, Share
A , 5.25
B, 3.26
C, 4.34
];

Or_0-1661177698690.png

 

beck_bakytbek
Master
Master
Author

@Or  AND @Lakshminarayanan_J  thanks a lot for your time and your help