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: 
JuMo
Creator
Creator

Is it possible to calculate a cumulative in a loading script ?

I am importing the following data 

 

Test1:
LOAD * INLINE [
Test1.Year, Test1.Month, p_type, Amount
2021, 01, a, 10
2021, 01, b, 8
2021, 02, a, 3
2021, 02, a, 5
2021, 02, b, 10
2021, 03, a, 9
2021, 03, a, 10
2021, 03, b, 7
2021, 03, b, 6
];

 

Is it possible, during the loading script to add a calculated column that represent the the cumulated value but only for one p_type ?

 

What I want to obtain is the following table :

 

YearMonthp_typeAmountCumul Amount
20211a1010
20211b88
20212a313
20212a518
20212b1018
20213a927
20213a1037
20213b725
20213b631
Labels (2)
2 Solutions

Accepted Solutions
Mark_Little
Luminary
Luminary

Hi

You will be able to achieve this by applying an order on load and using the Peek function. 

Mark

View solution in original post

JuMo
Creator
Creator
Author

Thanks for your hint,

I have the following (satisfactory) solution:

Test1:
LOAD * INLINE [
Test1.Year, Test1.Month, p_type, Amount
2021, 01, a, 10
2021, 01, b, 8
2021, 02, a, 3
2021, 02, a, 5
2021, 02, b, 10
2021, 03, a, 9
2021, 03, a, 10
2021, 03, b, 7
2021, 03, b, 6
];
 
 
 
Test2:
Load 
Test1.Year as Test2.Year,
    Test1.Month as Test2.Test1Month,    
    p_type as Test2.p_type, 
    Amount as Test2.Amount,
    Amount+Peek('AmountYTD',-1,'Test2') As AmountYTD
Resident Test1;

 

View solution in original post

2 Replies
Mark_Little
Luminary
Luminary

Hi

You will be able to achieve this by applying an order on load and using the Peek function. 

Mark

JuMo
Creator
Creator
Author

Thanks for your hint,

I have the following (satisfactory) solution:

Test1:
LOAD * INLINE [
Test1.Year, Test1.Month, p_type, Amount
2021, 01, a, 10
2021, 01, b, 8
2021, 02, a, 3
2021, 02, a, 5
2021, 02, b, 10
2021, 03, a, 9
2021, 03, a, 10
2021, 03, b, 7
2021, 03, b, 6
];
 
 
 
Test2:
Load 
Test1.Year as Test2.Year,
    Test1.Month as Test2.Test1Month,    
    p_type as Test2.p_type, 
    Amount as Test2.Amount,
    Amount+Peek('AmountYTD',-1,'Test2') As AmountYTD
Resident Test1;