Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
An issue has been identified on Qlik Cloud hub, please visit our Status Update Page for details: GET THE LATEST
cancel
Showing results for 
Search instead for 
Did you mean: 
praveenkumar_s
Creator II
Creator II

Need to add values based on before two dates

Hi friends,

I have date and cost column. all i need is just one more field which consists of total cost for current day + last two days in load script.

Please find the attached screenshot below.

source.PNG

Please let me know in case of any clarifications.

1 Solution

Accepted Solutions
boorgura
Specialist
Specialist

Please try the below:

load *, rangesum(Cost, peek(Cost, -1), peek(Cost,-2)) as Total;

LOAD * Inline [

Date, Cost

2/2/2018 , 10

2/3/2018 , 20

2/4/2018 , 50

2/5/2018 , 60

2/6/2018 , 70

2/7/2018 , 20

2/8/2018 , 50

2/9/2018 , 60

2/10/2018 , 90

2/11/2018 , 15

2/12/2018 , 20

2/13/2018 , 25

];

View solution in original post

13 Replies
shiveshsingh
Master
Master

use this expression

=rangesum(sum(Cost),Above(Cost,1),Above(Cost,2))

eduardo_dimperio
Specialist II
Specialist II

Hi Kumar,

Use Peek(Total)+Cost AS TOTAL

shiveshsingh
Master
Master

Capture.JPG

praveenkumar_s
Creator II
Creator II
Author

Thanks. but i just want that in load script.  i want to add more field named total in load script.

praveenkumar_s
Creator II
Creator II
Author

Hi Eduardo,

Total you are referring inside peek function is the column i just want to create.

i want it in load script . so only i can generate charts.

eduardo_dimperio
Specialist II
Specialist II

Peek() is a script function

praveenkumar_s
Creator II
Creator II
Author

yes i agree. but i just want to know what is the field "total" you used inside peek function?

and also i need to get the addition of above two rows only.

eduardo_dimperio
Specialist II
Specialist II

Ah, ok...Try this

Peek(Cost,1)+Peek(Cost,2) AS TOTAL



boorgura
Specialist
Specialist

Please try the below:

load *, rangesum(Cost, peek(Cost, -1), peek(Cost,-2)) as Total;

LOAD * Inline [

Date, Cost

2/2/2018 , 10

2/3/2018 , 20

2/4/2018 , 50

2/5/2018 , 60

2/6/2018 , 70

2/7/2018 , 20

2/8/2018 , 50

2/9/2018 , 60

2/10/2018 , 90

2/11/2018 , 15

2/12/2018 , 20

2/13/2018 , 25

];