Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How can I Iterate through Multiple Years of Accounting Data?

skeppi
5 - Atom

Hey there and welcome to my first post 🙂

 

The Story

Provided is a dataset of transactions (purchases and sales of stocks) that covers multiple years (example data reduced to one asset over 3 years). These assets need to be valuated at the end of each year t and the valuation at the end of t0 is the basis for the subsequent calculations in year t+1.

 

Valuation is as follows:

  • Quantities of the asset are purchased and sold throughout the year
  • Ongoing valuation is based on the average purchasing price per piece
  • At year end, ongoing valuation will be higher or lower than actual stock exchange price and depreciation or appreciation needs to be considered
  • Depreciation/appreciation affects valuation of subsequent year
  • I calculate the necessary fields linearly with formulas, multirow-formulas and running totals

 

Problem

Above approach leads to a circular reference as of t+1 because the valuation per piece in t+1 is affected by the depreciation in t0. So my column “AvgPricePerPiece” at the start of t+1 needs to incorporate the depreciation from the end of t0, but I cannot take it into account, because the depreciation calculation comes after the valuation per piece calculation. The average price per piece at the start of 2021 (cell Q30 in output-file) needs to incorporate the depreciation of 2020 (cell U29).


How can I solve the problem of not being able to run this calculation block by block (1 year = 1 block) without duplicating my existing workflow for each occurring year?

5 REPLIES 5
wonka1234
10 - Fireball

Not at my PC right now - but  do you need to use previous rows to calculate current row?

I did something similar for an amortization schedule where I built a macro to loop through rows and use previous row for current row calculations.

 

Check out the macro here:

https://community.alteryx.com/t5/Public-Community-Gallery/Using-Previous-Row-Balance-Number-for-Next...

 

 

skeppi
5 - Atom

Hi Wonka. Unfortunately this doesn't solve my problem.

rartt
Alteryx
Alteryx

@bensilv please could you take a look at Andreas query?

@skeppi thanks for your first post on Community!

Christina_H
14 - Magnetar

I've created an iterative macro for this type of problem before, see attached (solution to Solved: Inventory Tracking - Alteryx Community)  This calculates the values row by row based on previous data.  Can you adapt this method to your data?

skeppi
5 - Atom

Thanks @rarrt for pushing this. I found the solution (an iterative macro) in one of the answers for @Christina_H's topic:

 

Solved: Best way to calculate row by row as next row requi... - Alteryx Community

(the post by CharlieS with the attachment 20180906-FinancialGeneration.yxzp)

Labels