Discussion board where members can get started with Qlik Sense.
Is it better to use a loop to do the calculations or use the summation of geometric series?
5(1.02)+5(1.02)^2+5(1.02)^3 + ... + 5(1.02)^10
should I use a loop ? for i = 1 to 10
or use the geometric series summation 5(1.02) * ( 1- 1.02^10)/(1-1.02) ?
I don't want to use PV or FV
If the calculation is performed for a small amount of data, I do not see any fundamental difference.
But in general it's just interesting, why do not you want to use functions PV or FV?
What if the calculation is being performed or a large amount of data?
I am very new to qlik sense and that's why I am asking.
As for not using PV or FV functions, there isn't any reason. I will be using them in my codes but for this one specific script I don't want to use them because it would be easier to manipulate the whole equation using the summation or loop. (it is a specific case)
Like an idea, please see this files Yandex.Disk andYandex.Disk (for some reason they could not be attached here). In them, I tried to simulate the settlement process for your both options. For 10 million lines, the calculation the first option was a little faster.
You can replace the calculation in this model with another one and again measure the result by reloading the data. The number of downloadable records can be changed.
Just in case the script code of the first file
RecNo() as LoopID,
5*1.02+5*Pow(1.02,2)+5*Pow(1.02,3)+5*Pow(1.02,4)+5*Pow(1.02,5)+5*Pow(1.02,6)+5*Pow(1.02,7)+5*Pow(1.02,8)+5*Pow(1.02,9)+5*Pow(1.02,10) as ValueLoop
Tthe script code of the second file
RecNo() as GeometricID,
5*(1.02)*(1- Pow(1.02,10))/(1-1.02) as ValueGeometric