Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
renjithpl
Specialist
Specialist

Multiple level aggregation in script

HI All,

I have an aggregated value based on ID and dim1, In the front end it works fine, but I want to get this in the script level like below code.

can I get same like in the first table using script level coding. ?

 

qlik.PNG

test:
LOAD * INLINE [
ID, dim1, dim2, dim3, value1, value2
1, a, tt, ooo, 10, 50
1, a, xx, ppp, 20, 30
2, b, yy, qqq, 5, 20
2, b, zz, rrr, 3, 10
2, c, pp, sss, 8, 40
3, d, qq, ttt, 9, 90
4, e, rr, uuu, 5, 100
5, f, ll, vvv, 12, 80
]
;
NoConcatenate
Table1:
LOAD ID, dim1, dim2, dim3,
sum(value1) as value1,
sum(value2) as value2
Resident test
Group by ID, dim1dim2, dim3;
left join(Table1)
LOAD IDdim1,
sum(value1) as value1aggr
Resident test
group by ID, dim1;
drop table test;

Labels (1)
1 Solution

Accepted Solutions
MayilVahanan

HI @renjithpl 

Try like below

MayilVahanan_0-1605675169477.png

test:
LOAD * INLINE [
ID, dim1, dim2, dim3, value1, value2
1, a, tt, ooo, 10, 50
1, a, xx, ppp, 20, 30
2, b, yy, qqq, 5, 20
2, b, zz, rrr, 3, 10
2, c, pp, sss, 8, 40
3, d, qq, ttt, 9, 90
4, e, rr, uuu, 5, 100
5, f, ll, vvv, 12, 80
];
NoConcatenate
Table1:
LOAD ID, dim1, dim2, dim3,ID&'-'&dim1 as Key,
sum(value1) as value1,
sum(value2) as value2
Resident test
Group by ID, dim1, dim2, dim3;

Join
LOAD Key,
FirstValue(dim2) as dim2,
FirstValue(dim3) as dim3,
sum(value1) as value1aggr
Resident Table1
group by Key;
drop table test;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

1 Reply
MayilVahanan

HI @renjithpl 

Try like below

MayilVahanan_0-1605675169477.png

test:
LOAD * INLINE [
ID, dim1, dim2, dim3, value1, value2
1, a, tt, ooo, 10, 50
1, a, xx, ppp, 20, 30
2, b, yy, qqq, 5, 20
2, b, zz, rrr, 3, 10
2, c, pp, sss, 8, 40
3, d, qq, ttt, 9, 90
4, e, rr, uuu, 5, 100
5, f, ll, vvv, 12, 80
];
NoConcatenate
Table1:
LOAD ID, dim1, dim2, dim3,ID&'-'&dim1 as Key,
sum(value1) as value1,
sum(value2) as value2
Resident test
Group by ID, dim1, dim2, dim3;

Join
LOAD Key,
FirstValue(dim2) as dim2,
FirstValue(dim3) as dim3,
sum(value1) as value1aggr
Resident Table1
group by Key;
drop table test;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.