Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Please let me know in case of any clarifications.
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
];
use this expression
=rangesum(sum(Cost),Above(Cost,1),Above(Cost,2))
Hi Kumar,
Use Peek(Total)+Cost AS TOTAL
Thanks. but i just want that in load script. i want to add more field named total in load script.
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.
Peek() is a script function
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.
Ah, ok...Try this
Peek(Cost,1)+Peek(Cost,2) AS TOTAL
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
];