Skip to main content

Lesson 6 · Repeated information: Tables and Subforms

M
Written by Mairu

Path

Duration

Level

Before you start

🔵 Configurator · Level 1

40 min

Intermediate

[[05 · Tu primer formulario

Your first form]]

Many processes record the same type of data several times: ten weighings, several temperatures, the spare parts of a repair. How you store them decides whether you'll later be able to calculate an average or draw a chart. This is one of the most important design decisions in Mairu.

🎯 By the end you'll know

  • How to tell when to use a Table and when a Subform.

  • How to create a subform, limit its number of responses and inherit information from the parent form.

  • How to create a checklist-style table.


🧠 The idea: fixed positions or records of the same type?

Both tools let you record several pieces of data within a single response, but they store them differently.

Table

Subform

What it is

A grid of rows and columns within the form

A form inside another

How it stores the data

Each cell is a distinct position

Each line is its own response, linked to the parent response

Ideal for

Fixed structures: matrices, checklists

Repeated records of the same type that will be analyzed together

Examples

Cleaning / Guards / Signage

10 weighings, 20 temperatures, several defects

The question that decides it: are the values positions in a fixed structure, or are they records of the same type that I'll need to analyze together?

Imagine ten weighings stored in a table as Weight 1, Weight 2… Weight 10. They look fine, but when you want to know the average weight of all the controls for the month or chart its trend, you'll have ten separate columns instead of a single piece of data. With a subform, all the weighings use the same peso field, and calculating averages, maximums or charts is immediate.

⚠️ Rule of thumb: if you're about to create fields called Weight 1, Weight 2, Weight 3…, stop and use a subform with a single Weight field.


🛠️ Guided practice: the weighings of the control

Step 1 · Create the Weighings subform

  1. Open the Packaging control in the Form Builder and click New field → Subform.

  2. Title: Weighings. ID: pesadas.

  3. Choose create a new one. Another Form Builder opens: design it with these fields:

Title

Type

ID

Configuration

Weight (g)

Numeric

peso

Required

Line

Asset selector

linea

Will be inherited from the parent

Batch

Short text

lote

Will be inherited from the parent

  1. Save the subform, go back to the main form, click reload and select it.

Step 2 · Limit the number of weighings

In the component, set 5 as the maximum number of responses. Once it reaches five, the Add button stops being available. If you leave it empty, there's no limit.

Step 3 · Inherit information from the parent

In the component's settings, relate the inherited fields: linea → linea and lote → lote. That way each weighing knows which line and batch it belongs to without the operator having to type it again. Only fields of the same type can be related.

💡 Why repeat line and batch in each weighing, if they're already in the parent? Because when you analyze the weighings separately (in a query or in Power BI) each record will carry that context with it. Also, Mairu always stores in each weighing the identifier of its parent response, so the relationship is never lost.

Step 4 · A checklist-style table

The weighings are repeated records; the review of the line before starting up, on the other hand, is a fixed structure. Add a Table called Pre-start review with:

  • Rows: Cleaning, Labeler, Metal detector.

  • Columns: Status and Observations. For each column choose its field type (for example, text for the observations) and add a description as help.


🔍 Check that it works

  • Create a control and add five weighings: the Add button disappears once it reaches five.

  • Open a weighing: it already carries the line and batch of the control.

  • Download the control as a PDF: the weighings and the table appear.


⚠️ Common mistakes

  • Using a table for measurements that are going to be analyzed. It's the costliest design mistake to fix afterwards, because the data already recorded can't be reconverted.

  • Putting a subform inside another. It's not possible: a subform cannot contain subforms.

  • Using the same subform twice in a form. A form cannot contain the same subform twice. If you need two types of detail, create two different subforms.

  • Not seeing the newly created subform. Save it, go back to the main form and click reload.


🏋️ Challenge

Quality also wants to record the defects found in each control: type of defect (from the Rejection reasons Entity), number of units affected and a photo. There may be none or many. Decide whether it's a table or a subform, build it and justify your decision with this lesson's key question.


📚 Learn more

➡️ Next lesson: Rules - a form that reacts

Did this answer your question?