I don't think you can tell QlikView how to join tables directly so you have to get a bit sneaky about it. I think something like the following would work but it's untested...
SQL Select * From Table1;
INNER JOIN (Tab1)
,Percentile AS Percentile_T2
SQL Select * From Table2;
This will join all rows where Key1 and Key2 both match.
Now you can group and sum, but judging by your query above you only want to do this where Percentile >= Percentile2, so:
LEFT JOIN (Tab1)
,Sum(Metric1) AS Accum1
,Sum(Metric2) AS Accum2
WHERE Percentile >= Percentile2
GROUP BY Key1, Key2, Percentile;
I think that might get you close...
Hope this helps,
Load your data into a table (lowest level of granularity).
Then aggregate using a Resident table.
Load index, Cum1, Cum2, ...
From File1.qvd (qvd);
Load Index, Sum(Cum1) as Cum1, Sum(Cum2) as Cum2, ...
Resident Tbl group by index;
Drop Table Tbl;
Unless you are trying to get an incremental aggregation, then use Excel (i.e. b2 = b1 + a2, b3= b2 + a3, etc.)
Thanks Jagan, A very useful tip. Just in case anyone is interested I have extened this to give me cumulative subtotals based on changes in F1.
LOAD * INLINE [
F1, F2, F3
RangeSum(F3, Peek('CumAll')) as CumAll,
if(F1<> previous(F1),F3,RangeSum(F3, Peek('CumF1'))) AS CumF1
DROP TABLE Data;
I found you need to be careful about the preceeding load so have done it in two passes - It worked for me on a real fife problem.