Forum Discussion

brunoguedes's avatar
brunoguedes
Frequent Visitor
9 years ago
Solved

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 highlighte...
  • MFelix's avatar
    MFelix
    9 years ago

    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