# Variable Within Repeat Not Recognized?

**URL:** <https://community.blaze.today/t/variable-within-repeat-not-recognized/38978>\
**Category:** Questions and Help\
**Created:** [July 9, 2024, 2:31pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978 "2024-07-09T14:31:03Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajduna7](https://community.blaze.today/user_avatar/community.blaze.today/ajduna7/32/11768_2.png) [@ajduna7](https://community.blaze.today/u/ajduna7)\
**Post date:** [July 9, 2024, 2:31pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/1 "2024-07-09T14:31:03Z")

</div>

Hi TB Community!

I am trying to reference a variable that is within a "repeat" function. Please see below:

 ![image](https://community.blaze.today/uploads/default/original/2X/4/4c279188ebf6fd7ad6a669a606c66767f6885275.png)  
When I preview the snippet, it gives me the error below  
 ![image](https://community.blaze.today/uploads/default/original/2X/0/0e19ed1765a5976ebc7867b2d46464755973e515.png)

I have checked the spelling multiple times. Also- This variable doesn't show up in the "sidebar" to be able to be selected.

I really appreciate any suggestions 😀

---

<div class="post-metadata">

**Author:** ![Dylan](https://community.blaze.today/user_avatar/community.blaze.today/dylan/32/5609_2.png) [@Dylan](https://community.blaze.today/u/Dylan)\
**Post date:** [July 9, 2024, 2:51pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/2 "2024-07-09T14:51:49Z")

</div>

Hi!

It looks like there's a lot going on in the snippet, so it's a little hard to see what could be causing the issue. Could you share the snippet here (click the gear icon) or share it with me at [dylan@blaze.today](mailto:dylan@blaze.today) so I can take a look?

---

<div class="post-metadata">

**Author:** ![ajduna7](https://community.blaze.today/user_avatar/community.blaze.today/ajduna7/32/11768_2.png) [@ajduna7](https://community.blaze.today/u/ajduna7)\
**Post date:** [July 9, 2024, 3:11pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/3 "2024-07-09T15:11:20Z")

</div>

Sure thing! Inserted below:

{note}Property Type: {formmenu: default=; Single Family; Multifamily; name=tablepropertytype}{endnote}  
{if: tablepropertytype="Single Family"; trim=yes}

Bed-Bath Count: Rental Rate: Expiration: {repeat: 1; locals=properties}{formmenu: default=3-Bed 1-Bath; 4-Bed 1-Bath; 5-Bed 1-Bath; 3-Bed 2-Bath; 4-Bed 2-Bath; name=tableunitmix} {note}{formmenu: default=Occupied; Vacant; name=multifamoccupancy}{endnote}{if: multifamoccupancy="Occupied"}${formtext: cols=10; default={=replace(catch({site: text; page=[https://now.mlsmatrix.com/](https://now.mlsmatrix.com/)\*; select=ifneeded; selector=.multiLineDisplay .multiLineDisplay .multiLineDisplay .multiLineDisplay:nth-child(1) .d48m8 \> .wrapped-field}, ""), "$", "")}; name=tablerentinfo}{else}{tablerentinfo="Vacant"}Vacant{endif} {if: multifamoccupancy="Vacant"}{tablerentexpiration="N/A"}N/A{endif}{note}{if: multifamoccupancy="Occupied"}{formmenu: default=Custom; Month-to-Month; name=tablerent; cols=10}{endif}{endnote}{if: tablerent="Custom"}{formtext: cols=10; name=tablerentexpiration}{endif}{if: tablerent="Month-to-Month"}{tablerentexpiration="M2M"}Month-to-Month{endif}{endrepeat} {endif}{note}{if: tablepropertytype="Multifamily"}Number of Units:{formmenu: default=; 2 Units; 3 Units; 4 Units; name=unitamount}{endif}{endnote}  
{if: tablepropertytype="Multifamily"; trim=yes}{if: unitamount="2 Units"; trim=yes}

Unit Mix: Rent: Expiration: {repeat: 2; locals=properties}{formmenu: 1-Bed 1-Bath; default=2-Bed 1-Bath; 3-Bed 1-Bath; name=tableunitmix} {note}{formmenu: default=Occupied; Vacant; name=multifamoccupancy}{endnote}{if: multifamoccupancy="Occupied"}${formtext: cols=10; default={=replace(catch({site: text; page=[https://now.mlsmatrix.com/](https://now.mlsmatrix.com/)\*; select=ifneeded; selector=.multiLineDisplay .multiLineDisplay .multiLineDisplay .multiLineDisplay:nth-child(1) .d48m8 \> .wrapped-field}, ""), "$", "")}; name=tablerentinfo}{else}{tablerentinfo="Vacant"}Vacant{endif} {if: multifamoccupancy="Vacant"}{tablerentexpiration="N/A"}N/A{endif}{note}{if: multifamoccupancy="Occupied"}{formmenu: default=Custom; Month-to-Month; name=tablerent; cols=10}{endif}{endnote}{if: tablerent="Custom"}{formtext: cols=10; name=tablerentexpiration}{endif}{if: tablerent="Month-to-Month"}{tablerentexpiration="M2M"}Month-to-Month{endif}{endrepeat} {endif: trim=yes}{if: unitamount="3 Units"; trim=yes}

Unit Mix: Rent: Expiration: {repeat: 3; locals=properties}{formmenu: 1-Bed 1-Bath; default=2-Bed 1-Bath; 3-Bed 1-Bath; name=tableunitmix} {note}{formmenu: default=Occupied; Vacant; name=multifamoccupancy}{endnote}{if: multifamoccupancy="Occupied"}${formtext: cols=10; default={=replace(catch({site: text; page=[https://now.mlsmatrix.com/](https://now.mlsmatrix.com/)\*; select=ifneeded; selector=.multiLineDisplay .multiLineDisplay .multiLineDisplay .multiLineDisplay:nth-child(1) .d48m8 \> .wrapped-field}, ""), "$", "")}; name=tablerentinfo}{else}{tablerentinfo="Vacant"}Vacant{endif} {if: multifamoccupancy="Vacant"}{tablerentexpiration="N/A"}N/A{endif}{note}{if: multifamoccupancy="Occupied"}{formmenu: default=Custom; Month-to-Month; name=tablerent; cols=10}{endif}{endnote}{if: tablerent="Custom"}{formtext: cols=10; name=tablerentexpiration}{endif}{if: tablerent="Month-to-Month"}{tablerentexpiration="M2M"}Month-to-Month{endif}{endrepeat} {endif: trim=yes}{if: unitamount="4 Units"; trim=yes}

Unit Mix: Rent: Expiration: {repeat: 4; locals=properties}{formmenu: 1-Bed 1-Bath; default=2-Bed 1-Bath; 3-Bed 1-Bath; name=tableunitmix} {note}{formmenu: default=Occupied; Vacant; name=multifamoccupancy}{endnote}{if: multifamoccupancy="Occupied"}${formtext: cols=10; default={=replace(catch({site: text; page=[https://now.mlsmatrix.com/](https://now.mlsmatrix.com/)\*; select=ifneeded; selector=.multiLineDisplay .multiLineDisplay .multiLineDisplay .multiLineDisplay:nth-child(1) .d48m8 \> .wrapped-field}, ""), "$", "")}; name=tablerentinfo}{else}{tablerentinfo="Vacant"}Vacant{endif} {if: multifamoccupancy="Vacant"}{tablerentexpiration="N/A"}N/A{endif}{note}{if: multifamoccupancy="Occupied"}{formmenu: default=Custom; Month-to-Month; name=tablerent; cols=10}{endif}{endnote}{if: tablerent="Custom"}{formtext: cols=10; name=tablerentexpiration}{endif}{if: tablerent="Month-to-Month"}{tablerentexpiration="M2M"}Month-to-Month{endif}{endrepeat} {endif: trim=yes}{if: multifamoccupancy="Occupied"}\*\*\*Please note: Current rents should not be used for future projections, with most properties, you would either attempt to raise the rent with the current tenant(s) or find new tenant(s) at market rate rents.{endif}

---

<div class="post-metadata">

**Author:** ![Dylan](https://community.blaze.today/user_avatar/community.blaze.today/dylan/32/5609_2.png) [@Dylan](https://community.blaze.today/u/Dylan)\
**Post date:** [July 9, 2024, 3:38pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/4 "2024-07-09T15:38:12Z")

</div>

To add the snippet here in the community, you have to replace 'snippet contents' with your snippet by copying the commands in the snippet and pasting it where 'snippet contents' is in the text here.

I think the issue could be that the form field 'multifamoccupancy' is _within_ the repeat command, and the if statement is outside of it.

Could you potentially move the form field + note command it is inside of to outside of the repeat command? Please let me know if that works.

---

<div class="post-metadata">

**Author:** ![ajduna7](https://community.blaze.today/user_avatar/community.blaze.today/ajduna7/32/11768_2.png) [@ajduna7](https://community.blaze.today/u/ajduna7)\
**Post date:** [July 9, 2024, 3:55pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/5 "2024-07-09T15:55:01Z")

</div>

> [@Dylan](#):
>
> To add the snippet here in the community, you have to replace 'snippet contents' with your snippet by copying the commands in the snippet and pasting it where 'snippet contents' is in the text here.

Okay copy that, I tried adding in the snippet to the text box multiple ways, but It didn't seem to save when I replied

I will play with putting it within the repeat function

---

<div class="post-metadata">

**Author:** ![Dylan](https://community.blaze.today/user_avatar/community.blaze.today/dylan/32/5609_2.png) [@Dylan](https://community.blaze.today/u/Dylan)\
**Post date:** [July 9, 2024, 4:07pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/6 "2024-07-09T16:07:48Z")

</div>

Once you paste the contents of your snippet where it says 'snippet contents', you should see a preview of the snippet on the right side of the page where you preview your post.

If moving the form field doesn't work, please let me know and we can find another solution.

---

<div class="post-metadata">

**Author:** ![ajduna7](https://community.blaze.today/user_avatar/community.blaze.today/ajduna7/32/11768_2.png) [@ajduna7](https://community.blaze.today/u/ajduna7)\
**Post date:** [July 9, 2024, 10:12pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/7 "2024-07-09T22:12:18Z")

</div>

Ahhh gotcha okay, I just added the snippet contents to the left side, previously I was trying to add it directly to the right side. It is updated now 🙂

---

<div class="post-metadata">

**Author:** ![Dan\_Barak1](https://community.blaze.today/user_avatar/community.blaze.today/dan_barak1/32/2322_2.png) [@Dan\_Barak1](https://community.blaze.today/u/Dan_Barak1)\
**Post date:** [July 9, 2024, 10:30pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/8 "2024-07-09T22:30:24Z")

</div>

Hi @ajduna7 ,  
Because it's used within {repeat} there are multiple occurrences of the variable. To access them, use the locals setting:

{repeat: 3; locals=locals}  
{formtext: name=field}{endrepeat}  
{=locals[1].field}  
{=locals[2].field}  
{=locals[3].field}

---

<div class="post-metadata">

**Author:** ![ajduna7](https://community.blaze.today/user_avatar/community.blaze.today/ajduna7/32/11768_2.png) [@ajduna7](https://community.blaze.today/u/ajduna7)\
**Post date:** [July 10, 2024, 3:18am UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/9 "2024-07-10T03:18:59Z")

</div>

Thanks Dan- I have tried all variations of the following snippet, and I can't seem to get it to work.

 ![image](https://community.blaze.today/uploads/default/original/2X/f/f000be2608c1057d2915a8bc3ac5f8dbdb5a67fa.jpeg)

Currently I am getting the error: Unknown name "Locals"

Do you happen to have any other idea on how to structure this?

Just fyi- the name of my repeat function is "properties". The name of the variable I am trying to create an if/else command with is "multifamoccupancy"

Thank you

---

<div class="post-metadata">

**Author:** ![benjamin.tolfsen](https://community.blaze.today/letter_avatar_proxy/v4/letter/b/ecd19e/32.png) [@benjamin.tolfsen](https://community.blaze.today/u/benjamin.tolfsen)\
**Post date:** [July 10, 2024, 7:14am UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/10 "2024-07-10T07:14:24Z")

</div>

Hi! I took a look at your snippet, and tried a different approach.

{note}Amount of units: {formmenu: default=1; 2; 3; 4; 5; name=unitamount}{endnote}

Unit mix Rent Expiration {repeat: unitamount ; locals=properties}{formmenu: default=3-Bed 1-Bath; 4-Bed 1-Bath; 5-Bed 1-Bath; 3-Bed 2-Bath; 4-Bed 2-Bath; name=tableunitmix} {note}{formmenu: default=Occupied; Vacant; name=multifamoccupancy}{endnote}{if: multifamoccupancy="Occupied"}${formtext: cols=10; default={=replace(catch({site: text; page=[https://now.mlsmatrix.com](https://now.mlsmatrix.com){{^^%2F^^}}\*; select=ifneeded; selector=.multiLineDisplay .multiLineDisplay .multiLineDisplay .multiLineDisplay:nth-child(1) .d48m8 \> .wrapped-field}, ""), "$", "")}; name=tablerentinfo}{else}Vacant{endif} {if: multifamoccupancy="Vacant"}N/A{endif}{if: multifamoccupancy="Occupied"}{note}{formmenu: default=Custom; Month-to-Month; name=tablerent; cols=10}{endnote}{if: tablerent="Custom"}{formdate: YYYY-MM-DD}{endif}{if: tablerent="Month-to-Month"}Month-to-Month{endif}{endif}{endrepeat}   
{if: contains(properties, "\"multifamoccupancy\": \"Occupied\"")}\*\*\*Please note: Current rents should not be used for future projections, with most properties, you would either attempt to raise the rent with the current tenant(s) or find new tenant(s) at market rate rents.{endif}

 ![image](https://community.blaze.today/uploads/default/original/2X/3/311c4f55acf433c15070afee6cc6aa152b9adba6.png)

Also another version:

{note}Amount of units: {note: preview=no}{formmenu: default=1; 2; 3; 4; 5; name=unitamount}{endnote}  
{button: unitamount = 1  
; label=1}{button: unitamount = 2  
; label=2}{button: unitamount = 3  
; label=3}{button: unitamount = 4  
; label=4}{button: unitamount = 5  
; label=5}{endnote}

Unit mix Rent Expiration {repeat: unitamount ; locals=properties}{note: preview=no}{formtoggle: name=Vacant; default=no}{endnote}{formmenu: default=3-Bed 1-Bath; 4-Bed 1-Bath; 5-Bed 1-Bath; 3-Bed 2-Bath; 4-Bed 2-Bath; name=tableunitmix}{if: Vacant = Yes}{button: Vacant = No  
; label={{^^%E2%86%A9%EF%B8%8F^^}}}{else}{button: Vacant = yes  
; label={{^^%F0%9F%9F%A2^^}}}{endif} {if: Vacant = yes}Vacant{else}${formtext: cols=10; default={=replace(catch({site: text; page=[https://now.mlsmatrix.com](https://now.mlsmatrix.com){{^^%2F^^}}\*; select=ifneeded; selector=.multiLineDisplay .multiLineDisplay .multiLineDisplay .multiLineDisplay:nth-child(1) .d48m8 \> .wrapped-field}, ""), "$", "")}; name=tablerentinfo}{endif} {if: Vacant = yes}N/A{else}{note: preview=no}{formmenu: Custom; default=Month-to-Month; name=tablerent; cols=10}{endnote}{if: tablerent="Custom"}{formdate: YYYY-MM-DD; name=expirationdate}{button: tablerent = "Month-to-Month"  
; label={{^^%E2%86%A9%EF%B8%8F^^}}}{else}Month-to-Month{button: tablerent = "Custom"  
; label={{^^%F0%9F%93%85^^}}}{endif}{endif}{endrepeat}   
{if: contains(properties, "\"vacant\": yes")}\*\*\*Please note: Current rents should not be used for future projections, with most properties, you would either attempt to raise the rent with the current tenant(s) or find new tenant(s) at market rate rents.{endif}

 ![image](https://community.blaze.today/uploads/default/original/2X/9/95d9bb66f3e8ce50c14137be9dcee83271e290c7.png)

---

<div class="post-metadata">

**Author:** ![ajduna7](https://community.blaze.today/user_avatar/community.blaze.today/ajduna7/32/11768_2.png) [@ajduna7](https://community.blaze.today/u/ajduna7)\
**Post date:** [July 10, 2024, 12:14pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/11 "2024-07-10T12:14:01Z")

</div>

Hi Ben! Thank you so much for crafting a few different variants, your second snippet introduced me to "buttons" I didn't realize those existed within Textblaze.

In this case I am actually looking to get a better idea of how to "phrase/format" the "locals" setting that Dan mentioned earlier. In order to reference a variable within a repeat function.

How would I go about creating an if/else for a variable within a repeat function? Thank you

---

<div class="post-metadata">

**Author:** ![Gaurang\_Tandon](https://community.blaze.today/user_avatar/community.blaze.today/gaurang_tandon/32/3796_2.png) [@Gaurang\_Tandon](https://community.blaze.today/u/Gaurang_Tandon)\
**Post date:** [July 10, 2024, 12:44pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/12 "2024-07-10T12:44:15Z")

</div>

Hey Andrew! When you request the condition `multifamoccupancy="Occupied"` - do you mean to request it for each row of the table separately, or do you want to request that it be true for any row in the table?

---

<div class="post-metadata">

**Author:** ![ajduna7](https://community.blaze.today/user_avatar/community.blaze.today/ajduna7/32/11768_2.png) [@ajduna7](https://community.blaze.today/u/ajduna7)\
**Post date:** [July 10, 2024, 12:50pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/13 "2024-07-10T12:50:14Z")

</div>

> [@Dylan](#):
>
> If

Hi Guarang! Thanks for the speedy reply, I am hoping to have this text pop-up whenever, any row of the (repeat) table is marked as Occupied:

\*\*\*_Please note: Current rents should not be used for future projections, with most properties, you would either attempt to raise the rent with the current tenant(s) or find new tenant(s) at market rate rents._

---

<div class="post-metadata">

**Author:** ![Gaurang\_Tandon](https://community.blaze.today/user_avatar/community.blaze.today/gaurang_tandon/32/3796_2.png) [@Gaurang\_Tandon](https://community.blaze.today/u/Gaurang_Tandon)\
**Post date:** [July 10, 2024, 1:07pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/14 "2024-07-10T13:07:33Z")

</div>

I see. Can you try this then?

```plaintext
{if: count(filter(locals, x -> x.multifamoccupancy="Occupied"))>0}
Your text goes here
{endif}

```

Note that `locals` is a list containing one item for each of your rows. So if you have two rows, the `locals` list will look like this: `[{ multifamoccupancy: "Value from row 1" }, { multifamoccupancy: "Value from row 2" },]`. In my condition above, I filtered for rows that are occupied, and then made sure their count is more than zero.

Let me know if it works for you.

---

<div class="post-metadata">

**Author:** ![ajduna7](https://community.blaze.today/user_avatar/community.blaze.today/ajduna7/32/11768_2.png) [@ajduna7](https://community.blaze.today/u/ajduna7)\
**Post date:** [July 10, 2024, 1:27pm UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/15 "2024-07-10T13:27:35Z")

</div>

My man!! That worked perfectly!! The only thing I switched was "locals" to "properties" (the name of the repeat function)

Thank you so much! I love this software and the community

---

<div class="post-metadata">

**Author:** ![ajduna7](https://community.blaze.today/user_avatar/community.blaze.today/ajduna7/32/11768_2.png) [@ajduna7](https://community.blaze.today/u/ajduna7)\
**Post date:** [July 15, 2024, 3:15am UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/16 "2024-07-15T03:15:21Z")

</div>

Guarang- Another question for you sir!

Referencing the if/else you created (pasted below). If that text shows up, (the property is occupied at all). How would I send that info to Datablaze.

**So for example:** If the text shows up, because the property is occupied, how would I structure that / create a variable to be able to send a "yes" / "no" to a column named "occupied" in Datablaze?

**Your previously created if/else:**  
{if: count(filter(locals, x -\> x.multifamoccupancy="Occupied"))\>0}  
Your text goes here  
{endif}

---

<div class="post-metadata">

**Author:** ![Gaurang\_Tandon](https://community.blaze.today/user_avatar/community.blaze.today/gaurang_tandon/32/3796_2.png) [@Gaurang\_Tandon](https://community.blaze.today/u/Gaurang_Tandon)\
**Post date:** [July 15, 2024, 3:27am UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/17 "2024-07-15T03:27:50Z")

</div>

You can do it like so:

```plaintext
{occupied=count(filter(locals, x -> x.multifamoccupancy="Occupied")) > 0}
{if: occupied}
Your text goes here
{endif}

```

What I did here is to "lift" the condition (`... > 0`) into a separate variable assignment first (`occupied = `), and then used that variable directly in my `if` condition (`if: occupied`) in place of the condition. You can now send this variable to Data Blaze as needed.

---

<div class="post-metadata">

**Author:** ![ajduna7](https://community.blaze.today/user_avatar/community.blaze.today/ajduna7/32/11768_2.png) [@ajduna7](https://community.blaze.today/u/ajduna7)\
**Post date:** [July 15, 2024, 3:44am UTC](https://community.blaze.today/t/variable-within-repeat-not-recognized/38978/18 "2024-07-15T03:44:22Z")

</div>

> [@Gaurang\_Tandon](#):
>
> ```auto
> {occupied=count(filter(locals, x -> x.multifamoccupancy="Occupied")) > 0}
> {if: occupied}
> Your text goes here
> {endif}
> 
> ```

Amazing! This worked perfectly. Thank you again 😀
