Forum Discussion
Calculate cumulative rate
Hello,
I would like to calculate the cumulative rate of a query. See the image below:
The correct sum of accumulated rates is 6.29% in the year 2016 - based on the formula highlighted in the image. How do I get to this result?
HI brunoguedes,
In the formula the F1 without the bracets is refering to the name of the step in the query so you should refer to the previous step that is Renamed Columns, the easist way is to change that Renamed to F1 and then see the result, after that all of the customs colums you add should be change to F2, F3,... that way you will get the desired result.
Breaking down the formula for you:
if Date.Month([Date])=2 then (F1{[Index]-1}[F1]*[Value])+F1{[Index]-1}[F1]+[Value] else 0)
F1 = Refers to the name of the step you want to get information from
{[Index]-1} = Refers to the row in wich you want to get the information from the previous step use index column just to get the row number since index it's consecutive numbers the index of the current row -1 give you the previous row
[F1] = refers to the column you want to get the information from
What happened and for simplification terms I ussualy give the step and the new column the same name so that I can easily go back and forward in my code to reference everything.
Additional question just curious are you from Portugal?
Regards,
MFelix
14 Replies
- MFelix
Super User
Hi brunoguedes,Looking at the print you send and making the calculations based on the formula the result you have is correct, are the monthly values a sum of the daily values?
Regards,
Mfelix
- brunoguedesFrequent Visitor
The monthly values are manually entered into a table in MySql - it is not a sum of daily values.
- MFelix
Super User
I did the calculation in excel using the provided formula and values and got to 6.12% and not 6.29%.
Are there any errors in one of the formulas?
Mfelix
- brunoguedesFrequent Visitor