# SharinPix Form Formula: Referencing Repeated Section Fields

## Overview

{% hint style="info" %}
The Repeated Section question can be used to add any number of pre-defined sections when filling out a form. Each added section can contain its own set values which can be referenced inside formula fields.

This article covers the following:

* [Referencing Repeated Section Fields](#referencing-repeated-section-fields)
* [Demo: Displaying Comments Field Based on Broken Item Count](#demo-displaying-comments-field-based-on-broken-item-count)
  {% endhint %}

## Getting Started

### Referencing Repeated Section Fields

To reference a nested question from a repeated section in a formula field, use:

<mark style="color:$danger;">`<RepeatedQuestionApiName>.<NestedQuestionApiName>`</mark>

The above expression returns a **list** of all <mark style="color:$danger;">`<NestedQuestionApiName>`</mark> values.

#### Example:

Consider a repeated section with API name <mark style="color:$danger;">`RoomItems`</mark> with a nested question having API name <mark style="color:$danger;">`Status`</mark>

![](https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FdLtfA6Ya0zxNeBzUncQW%2F1.png?alt=media\&token=22878a9c-26a3-477d-a810-82c8f320e8f5)

![](https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FTnLrirgujVVSFcVch3hO%2F4%20\(1\).png?alt=media\&token=ff49d97e-3ca7-49d8-bf66-dea406f15b05)

In a formula field, you can reference the nested <mark style="color:$danger;">`Status`</mark> field as shown below:

![](https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FOnxOYFipatZ2elo1bB6O%2F2%20\(1\).png?alt=media\&token=c914fcec-45b5-4e34-970a-6186192e1a6f)

Because <mark style="color:$danger;">`Status`</mark> is inside the <mark style="color:$danger;">`RoomItems`</mark> repeated section, <mark style="color:$danger;">`RoomItems.Status`</mark> returns a **list of values** – one value for each added *Room Item*

<mark style="color:$danger;">`RoomItems.Status`</mark> will return <mark style="color:$danger;">`['Dirty', 'Clean', 'Broken']`</mark> for the *Room Items* below:

![](https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FaPU1o2U6SetFaXxrU6jG%2FDOC%20Mobile%20-%201920%20x%201080%20\(2\)%20\(1\).png?alt=media\&token=102b1108-763d-4ee9-818d-15fefb137f33)

## Demo: Displaying Comments Field Based on Broken Item Count

This example demonstrates referencing a repeated section field in a formula field within a Room Inspection example. If two or more items are broken, an additional required question will be visible to provide more information on the damage and follow-up actions required.

The diagram below shows a *text area* question configured with a visibility formula. This question is configured to be visible when two or more *Room Items* have *Status* "Broken"

The formula uses the <mark style="color:$danger;">`COUNTMATCHES`</mark> function to count the number of times the value <mark style="color:$danger;">`"Broken"`</mark> is found in the list returned by <mark style="color:$danger;">`RoomItems.Status`</mark>.

![](https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2FVt6lO0MqyYba5X6Hy7zI%2F3%20\(2\).png?alt=media\&token=07c04c1e-5db7-47b6-9206-7dc96a591556)

The diagram below shows the form filled with only one broken *Room Item.*

![](https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2F9Xgb10qmFF9I0yTlQuYe%2FDOC%20Mobile%20-%201920%20x%201080%20\(3\)%20\(1\).png?alt=media\&token=d914601c-7422-4093-ac38-afcdcfcc6f0a)

The diagram below shows the form with the *text area* question visible once a second broken *Room Item* is added.

![](https://2647402409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRD1Xcn9HtKcyfQ9Ghyk%2Fuploads%2F4ieqLxDokCxBEcBEfvno%2FDOC%20Mobile%20-%201920%20x%201080%20\(4\).png?alt=media\&token=44df2dbb-a0e9-4c0b-b1e1-a6415a4913db)
