Skip to content

5.4: For-Each Loops — Process Every Item, Then Collect

You know how to expand a list into a sub-table and do calculations on each row. But what happens when each row runs something that takes time — like an AI call, an API lookup, or a web search?

The challenge: the parent row needs to collect results only after all children are done. Otherwise it might run before half the AI calls have finished and produce incomplete results.

This section shows you the For-Each Loop pattern — the right way to:

  1. 🔄 Expand a list into child rows (the "for each" part)
  2. ⚙️ Run AI or any automation on every child independently and in parallel
  3. ✅ Wait until all children are done
  4. 📊 Collect all results back into the parent row

This is how real AI pipelines work

Every time you see "batch process," "analyze each item," or "summarize a list," this is the pattern you need. It's also how professional code handles parallel work — and Taibles makes it completely visual.


The Problem: Why Timing Matters

Imagine you have a research request with 5 topics. You want AI to write a paragraph about each topic, then combine them into a report.

What goes wrong without the loop pattern:

  1. Parent row is created with 5 topics
  2. Sub-table is created, 5 child rows appear
  3. AI starts analyzing each child — this takes 10–30 seconds each
  4. The parent "collect results" column fires immediately — but only 1 child is done!
  5. Parent produces a report with just 1 paragraph 😞

What you want:

  1. Parent row created, sub-table expands to 5 child rows
  2. AI runs on all 5 children in parallel
  3. Parent waits until all 5 are done
  4. Parent collects all 5 paragraphs and creates the full report ✅

The difference comes down to two settings you need to configure — let's build it.


Building Your First For-Each Loop

The Scenario

You're building a research assistant. Users submit a request with a list of topics to research. The system should:

  • Write a short analysis for each topic (using AI)
  • Combine all analyses into one final report

Parent table: Research Requests

  • Columns: request_title, topics (a list), final_report

Child table: Topics

  • Columns: topic_name, analysis (AI-generated)

Step 1: Set Up the Sub-Table

Start with a topics column in your parent table that contains an array of topic names. If you haven't done this before, follow 5.2 Creating Sub-Tables first.

After converting, you should have:

  • Parent table: Research Requests with a topics column showing the sub-table
  • Child table: Topics with a topic_name column per row

Step 2: Add AI to Each Child Row

In the Topics child table, add an AI column that analyzes each topic:

  1. Click "Add Column" in the Topics sub-table
  2. Choose "AI / LLM" as the column type
  3. Name it analysis
  4. Write a prompt like:
    Write a concise 2-3 paragraph analysis of the following topic:
    {{{topic_name}}}
  5. Set the dependency to topic_name

What happens: When a new child row appears, the AI column automatically fires and generates an analysis. This takes several seconds — and all 5 rows run at the same time (in parallel).

Parallel execution

All child rows run their columns independently at the same time. This is much faster than running them one-by-one, but it also means the parent can't know in advance when the last one will finish.


Step 3: Enable Completion Tracking on the Sub-Table Column

This is the key step most people miss. You need to tell the system: "watch the analysis column in the child table, and notify the parent when every row has a result."

In the parent Research Requests table:

  1. Hover over the topics column header
  2. Click the three-dot menu (⋮)
  3. Select "Edit column" (or "Configure")
  4. Scroll to the "Completion Tracking" section
  5. Enable "Track Completion"
  6. In the "Track Column" field, enter the column name to watch: analysis
  7. Save

What this does: The system now watches every child row's analysis cell. The moment the last child row's analysis cell changes to "Done", the system automatically re-triggers the parent row — signalling that all work is complete and results can be collected.

Think of it like a finish line

Each child row crosses the finish line when its analysis cell completes. The completion tracker waits at the finish line and rings a bell only when the very last runner has crossed.


Step 4: Add a "Pull Data" Column to Collect Results

Now add a column in the parent Research Requests table that collects all the analyses:

  1. Click "Add Column" in the parent Research Requests table
  2. Choose "Pull Data" as the column type
  3. Name it all_analyses
  4. Configure it:
    • Source Table: Topics (your sub-table)
    • Source Column: analysis
    • Filter by Parent Row: ON ✅ (only pull this parent's children)
    • Wait for All Rows to Complete: ON ✅

Save the column.

The "Wait for All Rows to Complete" setting is the second half of the mechanism. When this column runs, it first checks whether every child row has finished. If even one child is still running, it skips and waits — and will be re-triggered automatically once the last child finishes (thanks to Step 3).

When all children are done, it collects their analysis values into a list:

["Analysis of topic 1...", "Analysis of topic 2...", "Analysis of topic 3..."]

Step 5: Add a Column to Combine the Results

The all_analyses column gives you a list. Now add a column to turn that list into a readable report:

  1. Add a column of type "AI / LLM" or "Custom Code"
  2. Name it final_report
  3. Set dependency: all_analyses
  4. Use a prompt like:
    You have received the following research analyses, one per topic.
    Combine them into a coherent, well-structured report:
    
    {{{all_analyses}}}

Save. This column only runs after all_analyses has a value — which only happens after all children are done.


The Complete Flow

Here's what happens end-to-end when a user submits a new research request:

1. New row created in Research Requests
   └─ topics = ["AI Trends", "Climate Tech", "Space Economy"]

2. Sub-table expands → 3 child rows created in Topics
   ├─ Row 1: topic_name = "AI Trends"
   ├─ Row 2: topic_name = "Climate Tech"
   └─ Row 3: topic_name = "Space Economy"

3. AI runs in parallel on all 3 rows (takes ~15 seconds each)
   ├─ Row 1: analysis = "AI is transforming..." ✅
   ├─ Row 2: analysis = "Clean energy investment..." ✅
   └─ Row 3: analysis = "Commercial launch costs..." ✅

                          ▼  (Completion tracker: ALL 3 done!)
4. Parent row re-triggered automatically

5. Pull Data column collects all 3 analyses into a list

6. final_report column runs → combines list into a full report ✅

Time from start to finish: ~15 seconds (parallel, not 45 seconds sequential)


The Two Settings That Make It Work

SettingWhereWhat it does
Track Completion + Track ColumnSub-table column in parentWatches child rows; re-triggers parent when ALL are done
Wait for All Rows to CompletePull Data column in parentSkips if any child is still running; waits for re-trigger

Both must be configured. Either alone won't work:

  • Tracking without the Pull Data setting → parent re-triggers but collects before all children finish
  • Pull Data wait without tracking → parent is never re-triggered after children finish

Real-World Applications

This pattern applies wherever you process a list with AI or external services:

Content creation:

  • One blog post → List of sections → AI writes each section → Collect into full article

Data enrichment:

  • One company → List of employees → AI enriches each profile → Collect into company summary

Document processing:

  • One contract → List of clauses → AI reviews each clause → Collect risk summary

Quality control:

  • One batch → List of items → AI checks each item → Collect pass/fail report

Research:

  • One question → List of sources → AI extracts key facts from each → Combine into answer

Troubleshooting

The parent collects results too early (incomplete list)

You've probably enabled Pull Data's "Wait for All Rows" but haven't set up "Track Completion" on the sub-table column. Without tracking, the parent is never re-triggered after children finish, so Pull Data runs immediately when first triggered (and finds incomplete results).

Fix: Enable "Track Completion" on the sub-table column (Step 3) and make sure "Track Column" points to the right child column.

The parent never collects anything

Check that the column name in "Track Column" exactly matches the child column's technical name (not its display label). Column names are lowercase with underscores — e.g., analysis not Analysis.

Only some child results appear

One or more child rows may have failed. Check the cell status icons in the child table — failed cells show in red. The parent won't receive a full collection until all rows are Done (not Failed).


Summary

The For-Each Loop pattern is three connected pieces:

  1. Sub-table expands a list into parallel child rows
  2. Completion Tracking on the sub-table column watches for all children to finish
  3. Pull Data (with "Wait for All Rows") collects results once they're all ready

Once you understand this pattern, you can build AI pipelines that process any number of items automatically, in parallel, and deliver clean aggregated results to the parent — without any custom code.


Previous: 5.3 More ExamplesNext: 6.1 When Humans Need to Review

Built with VitePress