Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everybody!
I'm new to Qlik and I stumbled upon a problem in script load. I need to calculate a field (let's call it "NewField") in Table 1 based on specific values from a field in Table 2 (let's call it "Source"). Tables are linked via "ID" field. The logic of the calcualtion should be like this:
IF ID = 1
THEN sum of values in field Source for ID = 2 and 3 and 4
ELSE sum of values in field Source
(syntax is completely made-up just to illustrate the calcualtion that the ID=1 has a special formula behind)
Let's have an example:
Table2:
ID Value
1 1
2 2
3 3
4 4
Table1:
ID NewField
1 2+3+4=9
2 2
3 3
4 4
Do you have any ideas, please?
Something like this
Table2:
LOAD * INLINE [
ID, Value
1, 1
2, 2
3, 3
4, 4
];
Left Join (Table2)
LOAD 1 as ID,
Sum(Value) as NewValue
Resident Table2
Where Match(ID, 2, 3, 4);
Table1:
LOAD ID,
Alt(NewValue, Value) as NewField
Resident Table2;
DROP Table Table2;
Something like this
Table2:
LOAD * INLINE [
ID, Value
1, 1
2, 2
3, 3
4, 4
];
Left Join (Table2)
LOAD 1 as ID,
Sum(Value) as NewValue
Resident Table2
Where Match(ID, 2, 3, 4);
Table1:
LOAD ID,
Alt(NewValue, Value) as NewField
Resident Table2;
DROP Table Table2;
This is brilliant!! Thank you very much! 🙂