# Need help to overcome Cycle of Dependencies - Investment Calculator app

**URL:** <https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973>\
**Category:** Ask for Help\
**Created:** [May 21, 2023, 1:56am UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973 "2023-05-21T01:56:39Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hassan\_Nadeem](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/hassan_nadeem/32/72956_2.png) [@Hassan\_Nadeem](https://community.glideapps.com/u/Hassan_Nadeem)\
**Post date:** [May 21, 2023, 1:56am UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/1 "2023-05-21T01:56:39Z")

</div>

Hi everyone,

so I am stuck with this problem of Cyclic of Dependencies. I want to create an app where I put an ‘Opening Balance’ of a day. Then Investors put some Capital In or Withdraw their Capital. Through that I calculate their Closing Balance and the percentage of each balance.

Now for example we start with 1st January 2023 which is the very first day of trade.

January 1st 2023 - Opening Balance is $ 0

3 Investors come in and invest their capital:  
Mark: $500  
James: $1000  
John: $1500

Total investment for 1st January is: $3000.

That means:  
Marks share = 16.67%  
James share = 33.33%  
John share = 50%

Their closing balance is:  
Mark: $500  
James: $1000  
John: $1500

January 1st 2023 closing balance will also be: $3000.

Now on 14 February I update the balances.  
I check the balance and found out that last times $3000 has become $6000 in the trade. So I open my sheet and update the Opening Balance of 14 February to $6000.

Now what should happen is:  
based on the % of share from last trade, I should be able to calculate the investors opening balance.  
In this case:

I know from 1st January 2023 my investors closing share % was:  
Marks share = 16.67%  
James share = 33.33%  
John share = 50%

So on 14th February when I input the new opening balance of $6000, the opening balance of each investor should be as following:  
Mark: 16.67% \* $6000 = $1000  
James: 33.33% \* $6000 = $2000  
John: 50% \* 6000 = $3000

I hope I am making sense 😛 but if I am not feel free to look at the attached spreadsheet to have a better idea.

> **[TradingSheet](https://docs.google.com/spreadsheets/d/1z9KnIYMLtRWjzjGBzCopiHr_UFSmXs8QwOAMmS-ZDXY/edit#gid=683282342)**
>
> Reference
> 
> 01 Jan 23,14 Feb 23,09 Mar 23,14 Mar 23,30 Mar 23,15 Apr 23
> opening balance,$0,$35,000,$100,000,$150,000
> change since last TX $,$0,$17,500.00,$34,500.00,$18,500.00
> change since last TX %,0.00%,100.00%,52.67%,14.07%
> closing...

The only thing that is stopping me to achieve this on glide is Cyclic Dependencies which totally makes sense. Just can’t get my head over it.

 ![Cyclic dependencies](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/d/bd3696eda45ffe6a559e16198e0280a386354116.png)  
 ![tradingsheet](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/f/8fe639094514173f2d9ee0dd48d6fb60df614798.png)

The only manual entries in the app should be:

1. Opening balances of the day
2. Capital in by investors
3. Capital out by investors

Any help would be deeply appreciated.

---

<div class="post-metadata">

**Author:** ![Hugh\_van\_Niekerk](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/hugh_van_niekerk/32/72491_2.png) [@Hugh\_van\_Niekerk](https://community.glideapps.com/u/Hugh_van_Niekerk)\
**Post date:** [March 19, 2024, 6:01pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/2 "2024-03-19T18:01:45Z")

</div>

Hi - did you ever find a workaround for this? I am struggling with a similar issue with circular dependencies.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [March 19, 2024, 6:34pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/3 "2024-03-19T18:34:04Z")

</div>

To fix the circular dependency error, you need to check your flow of data from column to column.

Ultimately you are trying to use ColumnA in ColumnB which is then used somewhere along the line to determine the value in ColumnA. If columnA is required to calculate ColumnB, and ColumnB is used to calculate a value in ColumnA, then you’ve created a circle which would end up in a never-ending loop.

The answer is to study your logic and find out where you have created the circle.

---

<div class="post-metadata">

**Author:** ![Hugh\_van\_Niekerk](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/hugh_van_niekerk/32/72491_2.png) [@Hugh\_van\_Niekerk](https://community.glideapps.com/u/Hugh_van_Niekerk)\
**Post date:** [March 19, 2024, 10:48pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/4 "2024-03-19T22:48:18Z")

</div>

Thing I don’t understand is i can get it to work in GSheets without the circular dependency issue but not in Glide. Maybe I am missing something. I will start another thread on this, would be great to get your input @Jeff_Hager!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [March 19, 2024, 10:59pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/5 "2024-03-19T22:59:05Z")

</div>

> [@Hugh\_van\_Niekerk](#):
>
> Thing I don’t understand is i can get it to work in GSheets without the circular dependency issue but not in Glide.

Google Sheets can support circular dependency to an extent. Glide doesn’t support that at all.

All in all, you would have to check your flow to see why it happens.

---

<div class="post-metadata">

**Author:** ![Hassan\_Nadeem](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/hassan_nadeem/32/72956_2.png) [@Hassan\_Nadeem](https://community.glideapps.com/u/Hassan_Nadeem)\
**Post date:** [March 19, 2024, 11:13pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/6 "2024-03-19T23:13:55Z")

</div>

@Hugh_van_Niekerk ,

If you still need any help with this then feel free to schedule a call with me here: [Calendly - We Don't Code](http://www.calendly.com/wedontcode).

---

<div class="post-metadata">

**Author:** ![Hugh\_van\_Niekerk](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/hugh_van_niekerk/32/72491_2.png) [@Hugh\_van\_Niekerk](https://community.glideapps.com/u/Hugh_van_Niekerk)\
**Post date:** [March 19, 2024, 11:32pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/7 "2024-03-19T23:32:46Z")

</div>

So I see (roughly) where the issue is coming in, but I just don’t know how to get around it. It is pretty crucial to what I am trying to build so hoping it isn’t a complete blocker. You can see the GSheet logic below which doesn’t create an issue.

Col B, C, D, F: Hardcoded  
ColE: =if(E5=$E$5, 0, SUM($H$5:H5))  
ColG: =if(G5=$G$5, 0,E6_F6)  
ColH: =$C6_$I6/$C$3  
ColI: =($D6+$G6)

In your experience are there workarounds in Glide?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [March 19, 2024, 11:37pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/8 "2024-03-19T23:37:48Z")

</div>

Can you share a screenshot from glide where you see the error?

---

<div class="post-metadata">

**Author:** ![Hugh\_van\_Niekerk](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/hugh_van_niekerk/32/72491_2.png) [@Hugh\_van\_Niekerk](https://community.glideapps.com/u/Hugh_van_Niekerk)\
**Post date:** [March 19, 2024, 11:42pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/9 "2024-03-19T23:42:58Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/a/8a688ca85a337aa765a964f21fdddd5e4747ae98.png) - the data view

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/b/0b3c7ed26f9b5aa6b3b3b25a4cb4e708f39f60ce.png) - the error message I get now when I try adjust the ‘Growth Col’

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [March 19, 2024, 11:46pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/10 "2024-03-19T23:46:55Z")

</div>

> [@Hugh\_van\_Niekerk](#):
>
> ColE: =if(E5=$E$5, 0, SUM($H$5:H5))  
> ColG: =if(G5=$G$5, 0,E6_F6)  
> ColH: =$C6_$I6/$C$3  
> ColI: =($D6+$G6)

So Column E depends on Column H.

Column H depends on Column I.

Column I depends on Column G.

But the column G depends on column E, so there’s your circular.

---

<div class="post-metadata">

**Author:** ![Hugh\_van\_Niekerk](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/hugh_van_niekerk/32/72491_2.png) [@Hugh\_van\_Niekerk](https://community.glideapps.com/u/Hugh_van_Niekerk)\
**Post date:** [March 19, 2024, 11:49pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/11 "2024-03-19T23:49:48Z")

</div>

Yup, spot on! But the calc works 100% fine in GSheets. Are you aware of any way around this in Glide?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [March 19, 2024, 11:51pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/12 "2024-03-19T23:51:45Z")

</div>

I think the problem is that in your google sheet you are performing a calculation across 2 rows, so there is no actual circular dependency. In glide, calculations happen within the same single row. What you are doing in glide doesn’t match what you are doing in the google sheet.

---

<div class="post-metadata">

**Author:** ![Hugh\_van\_Niekerk](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/hugh_van_niekerk/32/72491_2.png) [@Hugh\_van\_Niekerk](https://community.glideapps.com/u/Hugh_van_Niekerk)\
**Post date:** [March 20, 2024, 12:00am UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/13 "2024-03-20T00:00:51Z")

</div>

Yup, I feared that might be the case. And is there a way of getting around that which you have seen?

Below is the structure for the GSheet for reference.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/8/a8d57a9b5b267f2dae3f16db6a29eeb83b091a84.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [March 20, 2024, 12:08am UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/14 "2024-03-20T00:08:13Z")

</div>

I don’t know enough about your data or what your goal is, but can you restructure your data so everything you need to perform a calculation is all on the same row as separate columns instead of multiple rows with different values shared in the same column but different rows? Otherwise, you may need some single value columns, or relations/lookups to retrieve values from other rows, and then change your calculations to use the single value columns or lookups as well.

---

<div class="post-metadata">

**Author:** ![Hugh\_van\_Niekerk](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/hugh_van_niekerk/32/72491_2.png) [@Hugh\_van\_Niekerk](https://community.glideapps.com/u/Hugh_van_Niekerk)\
**Post date:** [March 20, 2024, 3:59pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/15 "2024-03-20T15:59:07Z")

</div>

Thanks for the help everyone, appreciated. Will have a think about how I can refactor things to get around this.

---

<div class="post-metadata">

**Author:** ![mattwensing](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mattwensing/32/72905_2.png) [@mattwensing](https://community.glideapps.com/u/mattwensing)\
**Post date:** [March 31, 2024, 2:10pm UTC](https://community.glideapps.com/t/need-help-to-overcome-cycle-of-dependencies-investment-calculator-app/61973/16 "2024-03-31T14:10:01Z")

</div>

Hi @Hassan_Nadeem & @Hugh_van_Niekerk —

I’m the creator of a low/no-code modeling platform called Summit which handles financial models and circular dependencies through simulation, and can return the data as JSON that Glide can consume. Summit also solves for idempotency, unlike Google Sheets, so multiple concurrent users is no problem.

I’m looking for Glide users to test with—so this could be a win-win-win.

Shoot me a DM if you’re interested. I’d be happy to try to solve this with you. First step would be sharing your Google Sheet so I can verify the ability to replicate it in Summit.
