Forum Discussion

Casperserven1's avatar
3 years ago
Solved

Accumulating using previous

I am trying to fo tthe following and struggling - I am sure this is easy but just can't see it. New Hires Retirees Total Workforce 3 5 20 6 3 23 8 1 30 9 8 31 4 6 29 ...
  • Kishore_KVN's avatar
    3 years ago

    Hello Casperserven1 , 

    We can achieve this using multiple ways but I can recall and create using one way among them. 

    You may need to create four columns for this. 

    First two columns are index columns from '0' and '1' which can be created in Power Query Editor.

    For next two columns the DAX calculations looks as below:

    Reference = IF('Data Table'[Index] = 0, 'Data Table'[Total Workforce],LOOKUPVALUE('Data Table'[Total Workforce],'Data Table'[Index New],'Data Table'[Index]))
    Result = IF('Data Table'[Index]=0,'Data Table'[Reference],'Data Table'[Reference]+'Data Table'[New Hires]-'Data Table'[Retirees])

     

    Output looks like this:

     

    If this post helps, then please consider accepting it as the solution to help other members find it more quickly. Thank You!!