# Tutorial: Iterator tables (CurrentValue workaround)

**URL:** <https://connect.superhuman.com/t/tutorial-iterator-tables-currentvalue-workaround/17211>\
**Category:** Tips and Hacks\
**Created:** [July 14, 2020, 10:08pm UTC](https://connect.superhuman.com/t/tutorial-iterator-tables-currentvalue-workaround/17211 "2020-07-14T22:08:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Danyliuk](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/paul_danyliuk/32/27228_2.png) [@Paul\_Danyliuk](https://connect.superhuman.com/u/Paul_Danyliuk)\
**Post date:** [July 14, 2020, 10:08pm UTC](https://connect.superhuman.com/t/tutorial-iterator-tables-currentvalue-workaround/17211/1 "2020-07-14T22:08:00Z")

</div>

> ## Update: this is obsolete as a CurrentValue workaround
> 
> If your only need is to have nested loops and be able to reference outer `CurrentValue`, you should do this now with a `WithName()` construct like [here](https://connect.superhuman.com/t/launched-reuse-logic-and-create-nested-loops-with-the-new-withname-formula/19900)
> 
> However, the Iterator Tables pattern still holds up if you need to:
> 
> - create logic more complex than a ForEach loop in the ForEach loop — like in the video below there’s a “Do… While” loop that doesn’t just go over a defined collection of items.
> 
> - be able to monitor the execution of steps, catch and rerun failed steps — for that you could still use an iterator table like I did it [here](https://youtu.be/m6xq7VrH6mg?t=254) with the HLP Doc Distro Runner table — it is your model iterator table.

* * *

After answering the [CurrentValue issue](https://connect.superhuman.com/t/what-to-do-when-currentvalue-is-overloaded/12795/2) questions [so.](https://connect.superhuman.com/t/maintain-outer-scope-in-two-for-loops/14876) [many.](https://connect.superhuman.com/t/adding-multiple-rows-of-data-through-a-button-via-formula-map/15182/19) [times](https://connect.superhuman.com/t/outer-currentvalue-access/8048/27), I finally recorded the tutorial on a Coda data processing pattern I use as a workaround for this very problem. It involves creating single-row helper tables that store outer `CurrentValue` values into cells, so that they’re accessible in nested `Filter`s and `FormulaMap` loops. I call this pattern **Iterator tables** , and beside being a workaround for `CurrentValue`, these are very powerful for doing more complicated calculations

The video is ~40 minutes long. The first ~8 minutes explain the pattern using a simple example. The rest of the video discusses a much more advanced use. Also I noticed only now that my webcam window overlaps pieces of formulas 😅 sorry for that, see the sample doc below.

[![](https://global.discourse-cdn.com/coda1/original/3X/b/7/b7c346efb241442f608608259fb54761f85e8584.jpeg "Coda trick: Iterator tables") ](https://www.youtube.com/watch?v=uwdYqy3fxbw)

TL;DR:

- Create a single-row table with a button that first thing stores `CurrentValue` in each `FormulaMap` into a separate column. Then reference that column when you want to retrieve that value.

Pros:

- Elegantly works around the `CurrentValue` context issues. The table is like a collection of variables.
- Avoids [doc bloat because of buttons in each row](https://connect.superhuman.com/t/this-doc-is-too-big-to-sync/12848/7) — shrinks the doc tremendously if your table has lots of rows.
- You can build very complicated calculation logic there.
- You can break that logic down into steps, and examine for issues more easily, step by step.

Cons:

- Takes some effort to setup (but you know whom to hit up if you need some paid assistance 😉 )
- Most likely, you won’t be able to set up automation to run this for you. In one of my setups automations were failing with unspecified Coda error.
- Iterating over large datasets will generate hundreds or thousands of Coda “ops” (tiny edit operations), which are then sent very slowly (like, 4 per second) to Coda servers and synced to other collaborators. You’ll have to wait for the doc to save all changes before you can close the tab. You’ll know when it’s not finished yet — trying to close or reload the tab will show you a warning.
- Frugal free plan users: it adds 1 table and 1 row to your object and row count 😱

Also, the sample doc:

https://coda.io/embed/xv9Im73En6/_su22r?viewMode=embedplay&hideSections=true

Once again I remind you that I’m going to run a blog [codatricks.com](http://codatricks.com) — please subscribe for tricks like this. I’m ashamed to say it’s been a year and I still haven’t started publishing anything there, and I’m putting everything out in this Community instead. For me, writing articles is much harder than just spinning unrehearsed single take videos like this one. But I’ll get there.

---

<div class="post-metadata">

**Author:** ![erik](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@erik](https://connect.superhuman.com/u/erik)\
**Post date:** [August 17, 2020, 7:55pm UTC](https://connect.superhuman.com/t/tutorial-iterator-tables-currentvalue-workaround/17211/2 "2020-08-17T19:55:41Z")

</div>

Thank you! I’m going to have to check this out and will let you know if I have any questions. Sorry for the late reply it’s been a little hectic but I am back now working and improving on my doc.

---

<div class="post-metadata">

**Author:** ![Breno\_Nunes](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/breno_nunes/32/12706_2.png) [@Breno\_Nunes](https://connect.superhuman.com/u/Breno_Nunes)\
**Post date:** [August 21, 2020, 12:51am UTC](https://connect.superhuman.com/t/tutorial-iterator-tables-currentvalue-workaround/17211/3 "2020-08-21T00:51:51Z")

</div>

Hey, @Paul_Danyliuk.

Thank you very much for this tutorial.  
I have this doc that all my work depend on that was running really slow.  
It had a table with more de 2000 rows and seven buttons.  
After removing all buttons from this table, my Doc went from 129MB to 68MB in uncompressed size  
Your post should be in [coda.io](http://coda.io) help pages. 😀

My question is how do you think Coda will tackle performance and scalability, as Shishir say in his road map, when it has these very limiting issues?

> [@Announcing our Series C Funding](https://connect.superhuman.com/t/announcing-our-series-c-funding/17708):
>
> We’re excited to announce that we’ve raised an $80 million round led by Mamoon Hamid from Kleiner Perkins. If you’d like the full background on our newest investors and the overview of how we plan to use this investment to make Coda even better, you can see our full blog post at [https://coda.io/@coda/funding-the-future-of-coda](https://coda.io/@coda/funding-the-future-of-coda) We’re really excited by the opportunity to think even bigger at addressing your needs. As you know, we tend to move fast at Coda, so I don’t want to over-prescribe a roa…

---

<div class="post-metadata">

**Author:** ![Paul\_Danyliuk](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/paul_danyliuk/32/27228_2.png) [@Paul\_Danyliuk](https://connect.superhuman.com/u/Paul_Danyliuk)\
**Post date:** [August 21, 2020, 10:31am UTC](https://connect.superhuman.com/t/tutorial-iterator-tables-currentvalue-workaround/17211/4 "2020-08-21T10:31:35Z")

</div>

> [@Breno\_Nunes](#):
>
> My question is how do you think Coda will tackle performance and scalability, as Shishir say in his road map, when it has these very limiting issues?

I think in the best way possible 🙂

---

<div class="post-metadata">

**Author:** ![Jason-Tamulonis](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/jason-tamulonis/32/46956_2.png) [@Jason-Tamulonis](https://connect.superhuman.com/u/Jason-Tamulonis)\
**Post date:** [August 31, 2020, 3:28pm UTC](https://connect.superhuman.com/t/tutorial-iterator-tables-currentvalue-workaround/17211/5 "2020-08-31T15:28:46Z")

</div>

@Breno_Nunes We are intimately aware of the problem here and are actively working on some dramatic improvements. Performance issues can be a bit more complicated to address, so please stay tuned!

---

<div class="post-metadata">

**Author:** ![Tyler\_The\_NoCode\_Shop](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/tyler_the_nocode_shop/32/21426_2.png) [@Tyler\_The\_NoCode\_Shop](https://connect.superhuman.com/u/Tyler_The_NoCode_Shop)\
**Post date:** [June 14, 2021, 9:38pm UTC](https://connect.superhuman.com/t/tutorial-iterator-tables-currentvalue-workaround/17211/6 "2021-06-14T21:38:20Z")

</div>

@Paul_Danyliuk , wanted to hop on to say thank you. I’ve repeatedly struggled with needing to use AddRow with nested FormulaMaps and this iterator table concept is just the ticket.

---

<div class="post-metadata">

**Author:** ![Pawel\_Niewiadomski1](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/pawel_niewiadomski1/32/42677_2.png) [@Pawel\_Niewiadomski1](https://connect.superhuman.com/u/Pawel_Niewiadomski1)\
**Post date:** [June 10, 2024, 3:17pm UTC](https://connect.superhuman.com/t/tutorial-iterator-tables-currentvalue-workaround/17211/7 "2024-06-10T15:17:35Z")

</div>

If anybody finds this thread don’t implement this solution.

Go to [Launched: Reuse logic and create nested loops with the new WithName() formula - #44 by Tamerlan\_Kagarmanov](https://connect.superhuman.com/t/launched-reuse-logic-and-create-nested-loops-with-the-new-withname-formula/19900/44) and learn about WithName method that offers more elegant solution.

---

<div class="post-metadata">

**Author:** ![Paul\_Danyliuk](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/paul_danyliuk/32/27228_2.png) [@Paul\_Danyliuk](https://connect.superhuman.com/u/Paul_Danyliuk)\
**Post date:** [June 11, 2024, 10:37am UTC](https://connect.superhuman.com/t/tutorial-iterator-tables-currentvalue-workaround/17211/8 "2024-06-11T10:37:40Z")

</div>

Thanks for flagging. I updated the original post as well.

This solution still holds up but for different reasons. If the need is simply to allow a loop in a loop, WithName is indeed much better.
