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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
let12
Partner - Contributor II
Partner - Contributor II

Apply value to next record

Hello everyone,

we are defining our budget for one cost element which is the same budget quantity for all other cost element by date, company code, plant and profit center.

Unfortunetely for the other cost elements the budget quantity is 0 which needs the value of the first defined budget quantity. See below my data

_KEY_Date_ID _KEY_CompanyCode_ID _KEY_Plant_ID _KEY_ProfitCenter_ID _KEY_CostElement_ID Base Unit Quantity Betrag
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|0003100200 M3 1’378 -188’000
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|0084001505 - 0 34’000
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|0086500010 - 0 3’000
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|0086531050 - 0 17’000
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|0086600010 - 0 11’000
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|B0000400002 - 0 66’000

 

The goal is to bring the data like this:

_KEY_Date_ID _KEY_CompanyCode_ID _KEY_Plant_ID _KEY_ProfitCenter_ID _KEY_CostElement_ID Base Unit Quantity Betrag
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|0003100200 M3 1’378 -188’000
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|0084001505 - 1’378 34’000
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|0086500010 - 1’378 3’000
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|0086531050 - 1’378 17’000
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|0086600010 - 1’378 11’000
01.01.2024 100|0370 100|3722 100|0300|0000009200 100|B0000400002 - 1’378 66’000

 

If Base Unit = M3, take the Quantity and apply it to the other cost elements records by considering the Date, Company Code, Plant and Profit Center.

I need a script solution .

 

I hope someone can help me out here.

 

Labels (2)
1 Reply
marcus_sommer

Maybe in this way:

m: mapping load distinct RelevantKey, Quantity from X where Quantity > 0;

t. load *, applymap('m', RelevantKey, '#NV') as QuantityNew from X,