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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

precalculate mat in script

Hi everyone,

i hope you can help me. I have to precalculate the moving annual total (mat) over the last 12 months in the script. The best i show you some sample data and the result which i want to reach.

source table:

Bill_IDDateAmount
102.05.201040
223.10.201176
319.08.200993
428.02.201082
510.03.201134
609.11.200965
717.04.2010112
820.07.201028
921.06.2009103
1028.09.201139


target table:

Bill_IDDateAmountMAT
102.05.201040-

2

23.10.201176-
319.08.200993-
428.02.201082-
510.03.201134-
609.11.200965-
717.04.2010112-
820.07.201028-
921.06.2009103-
1028.09.201139-
-21.06.2009-0
-22.06.2009-0
-...-...
-01.07.2009.-103
-02.07.2009-103
-...-...
-01.09.2009-196 (= 103 + 93)
-...-...
-01.08.2010-420 (= 93 + 65 + 82 + 112 + 40 + 28)
-...-...
-23.10.2011-149 (= 76 + 39 + 34)


So, e.g. when i want to calculate the mat for 1st august 2010, it should be sum all bills within the august 2009 and july 2010. Also, each cumulative value in a month should be the same as you see in july 2009.

I'm thinking and rethinking about this and how to solve it in qlikview but didnt come to any solution.

Can you provide any help?

Thanks in advance

4 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

Please check the attachment for solution.

Regards,

Jagan.

Not applicable
Author

Hi,

thanks a lot for your solution. Now, I know what RangeSum does.

Still one question: assumed, i have 10000 bills within a period of 10 years. If i would precalculate the mat for the given last 12 months and save this for every date within the period, i would have about 3600 records. In the chart, I would only use the mat to visual the growth. Is it better to do this or to apply the rangesum function, from performance view?

Regards,

Philipp

jagan
Partner - Champion III
Partner - Champion III

Hi,

Applying the Expression would be better, because you need to use groupby to precalculate.  So, you may not be view accurately by dimensions.  If you do not need by dimensions then you can precalculate the values it is more better than calculating using RangeSum. 

I think for 10000 records, it is not a matter.

Regards,

Jagan.

Not applicable
Author

Hi,

i'm noticing when i select an unique month no mat will be calculated. Thats what you propably mean. But my aim is to visual the mat whether an unique month is selected or not. Then i had to calculate the mat in the script as you said.

But thats exactly what gives me headache. How do i do that?

Regards,

Philipp