# Array indexing within Set Variable module

**URL:** <https://community.make.com/t/array-indexing-within-set-variable-module/4802>\
**Category:** Questions\
**Tags:** arrays\
**Created:** [October 26, 2022, 11:21am UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802 "2022-10-26T11:21:32Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Robertson](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@Daniel\_Robertson](https://community.make.com/u/Daniel_Robertson)\
**Post date:** [October 26, 2022, 11:21am UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/1 "2022-10-26T11:21:32Z")

</div>

I am trying to convert a month represented by a number to a written month name, for example going from `9` to `September`. I have three sequential Set Variable modules:

**Variable 1 - previousMonthNumber**  
Uses the built-in date functions to take the current date, add -1 months to get the previous month, and formats it to just be the number month value:  
`{{formatDate(addMonths(now; -1); "M")}}`

Resulting variable value is: `9`  
  
  
**Variable 2 - monthsArr**  
Uses the built-in array functions to create a blank array, and populate it with the written months:  
`{{add(emptyarray; "January"; "February"; "March"; "April"; "May"; "June"; "July"; "August"; "September"; "October"; "November"; "December")}}`

Resulting variable value is: `["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]`

**Variable 3 - previousMonthRead**  
Should use the previous two variables to get the previous month as a written word. I thought it would be quite simple to do this using array indexing, as I would were I coding. I tried this:

 ![Screenshot 2022-10-26 at 12.11.33](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/5/5e69f92c11ad5430d2b1801d480851d69c89ac39.png)

However, the output of the above is:  
`"previousMonthRead": "January, February, March, April, May, June, July, August, September, October, November, December[9]"`

I have tried varying syntax changes such as `monthsArr.previousMonthNumber`, but nothing seems to work and the result is always some variation of the full array with the previousMonthNumber just added onto the end of it.

So, my question is, if not with standard indexing syntax, how do I do array indexing within the variable value definition box? I feel like I must be missing something really obvious because I thought this would be very simple to do.

I’d be grateful for any help!

---

<div class="post-metadata">

**Author:** ![alex.newpath](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/alex.newpath/32/84_2.png) [@alex.newpath](https://community.make.com/u/alex.newpath)\
**Post date:** [October 26, 2022, 11:27am UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/2 "2022-10-26T11:27:26Z")

</div>

> [@Daniel\_Robertson](#):
>
> {{formatDate(addMonths(now; -1); “M”)}}

Not sure why you’re making it this hard. The [mask token](https://www.make.com/en/help/functions/tokens-for-date-time-formatting) for the full month name is `MMMM`

`{{formatDate(addMonths(now; -1); "MMMM")}}`

will do this without array manipulation. It does seem that make is casting your number to a string and that array index approach breaks.

---

<div class="post-metadata">

**Author:** ![Daniel\_Robertson](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@Daniel\_Robertson](https://community.make.com/u/Daniel_Robertson)\
**Post date:** [October 26, 2022, 11:32am UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/3 "2022-10-26T11:32:44Z")

</div>

Did not know you could get the full month name with `MMMM`, thank you very much for that! I had not thought to look at the documentation for date formatting as I was focusing on the array. Appreciate the pointer.

Nonetheless, though, I would like to know how array indexing works. Even just trying `monthsArr[9]` (using 9 rather than the variable) fails.

---

<div class="post-metadata">

**Author:** ![alex.newpath](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/alex.newpath/32/84_2.png) [@alex.newpath](https://community.make.com/u/alex.newpath)\
**Post date:** [October 26, 2022, 11:37am UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/4 "2022-10-26T11:37:52Z")

</div>

> [@Daniel\_Robertson](#):
>
> Nonetheless, though, I would like to know how array indexing works. Even just trying `monthsArr[9]` (using 9 rather than the variable) fails.

This is a tricky thing to do as you have to put the number directly into the formatted array syntax. Can’t type it out manually. Take a snapshot of how you have the numeric index formatted.

As for the rest of it I encourage you to read all the docs. You’re going to start banging your head against the wall if you don’t thoroughly digest what make is. Start with this [thread](https://community.make.com/t/the-ultimate-make-documentation-topic/4386).

---

<div class="post-metadata">

**Author:** ![Daniel\_Robertson](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@Daniel\_Robertson](https://community.make.com/u/Daniel_Robertson)\
**Post date:** [October 26, 2022, 11:56am UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/5 "2022-10-26T11:56:38Z")

</div>

I appreciate your comments and I’ll be sure to peruse the documentation. I have been using Make/Integromat (and Zapier) for a few years now, and this is the first time I’ve really become stuck on something. Some additional context on this particular use case - I’m retrieving all rows within a Google Sheet that match a Google Charts query, turning that range into a .csv and attaching it to an email to be sent automatically on the first day of every month.

For the sake of clarity, I thought I’d just show you everything involved…

This is how I define the array:

 ![Screenshot 2022-10-26 at 12.47.56](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/1/14426432217906e0f7d2fafd92e74812a1f4e94e.png)

I can confirm that works by inspecting the output:

 ![Screenshot 2022-10-26 at 12.48.21](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/1/1fd44bc19784081e644a5b3517439612cd0ddeae.png)

This is how I’m doing the indexing with a number:

 ![Screenshot 2022-10-26 at 12.48.31](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/f/fa14ba6b64f5ad1eb0ee2558191517cdfb882411.png)

The result of that is the array is now a collection, as it contains my list of strings and an integer:

 ![Screenshot 2022-10-26 at 12.49.07](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/7/7871a334cc292d61686af45631b59e035af627a0.png)

---

<div class="post-metadata">

**Author:** ![alex.newpath](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/alex.newpath/32/84_2.png) [@alex.newpath](https://community.make.com/u/alex.newpath)\
**Post date:** [October 26, 2022, 11:59am UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/6 "2022-10-26T11:59:24Z")

</div>

The array reference is incorrect. The number has to go into the colour token between the [and].

---

<div class="post-metadata">

**Author:** ![Daniel\_Robertson](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@Daniel\_Robertson](https://community.make.com/u/Daniel_Robertson)\
**Post date:** [October 26, 2022, 12:04pm UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/7 "2022-10-26T12:04:12Z")

</div>

As far as I can tell, it’s not possible to edit that purple token or add a number between the square brackets. Am I missing something?

---

<div class="post-metadata">

**Author:** ![Daniel\_Robertson](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@Daniel\_Robertson](https://community.make.com/u/Daniel_Robertson)\
**Post date:** [October 26, 2022, 12:07pm UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/8 "2022-10-26T12:07:26Z")

</div>

I seem to have figured it out, my bad…

Rather than clicking the `monthsArr[]` token to insert the full variable reference, expanding the array and clicking the `[1]` token inserted the square bracket tokens, and I was then able to change the index number, and successfully extract a value from the array.

![Screenshot 2022-10-26 at 13.04.46](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/a/a32a3bac282b91d25166fb5fd682bf0bdc7f6c82.png)

 ![Screenshot 2022-10-26 at 13.08.37](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/1/13ff98f6ebbeb102f8bed292022a6284f36368a1.png)

Not hugely intuitive, and it does seem odd you can’t just type those square brackets manually or insert them from the ‘Functions for working with arrays’ box, but it works! Thanks again for the help.

---

<div class="post-metadata">

**Author:** ![alex.newpath](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/alex.newpath/32/84_2.png) [@alex.newpath](https://community.make.com/u/alex.newpath)\
**Post date:** [October 26, 2022, 12:24pm UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/9 "2022-10-26T12:24:15Z")

</div>

> [@Daniel\_Robertson](#):
>
> Not hugely intuitive, and it does seem odd you can’t just type those square brackets manually or insert them from the ‘Functions for working with arrays’ box, but it works! Thanks again for the help

Not at all but yes. Also you [can copy the whole expression and edit it in a text editor](https://community.make.com/t/remove-automatic-formula-pop-ups-please/1573/4). All expressions are just text and much easier to edit in a regular text editor and then paste back in. Try it!

---

<div class="post-metadata">

**Author:** ![Daniel\_Robertson](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@Daniel\_Robertson](https://community.make.com/u/Daniel_Robertson)\
**Post date:** [October 26, 2022, 12:29pm UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/10 "2022-10-26T12:29:37Z")

</div>

That is a lot easier indeed. Well I’ve learnt a few things doing this, so all good experience! Thanks for your time today, Alex, much appreciated. Consider me unstuck!

---

<div class="post-metadata">

**Author:** ![alex.newpath](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/alex.newpath/32/84_2.png) [@alex.newpath](https://community.make.com/u/alex.newpath)\
**Post date:** [October 26, 2022, 12:39pm UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/11 "2022-10-26T12:39:23Z")

</div>

Using [get()](https://community.make.com/t/extract-an-item-from-array-get-and-map-function-make-beginners-guide/2134) is even easier and it is probably easier to access dynamic array indices.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/2X/3/39cb911524b25c1c9068cff489b48365686c58ed.jpeg)

---

<div class="post-metadata">

**Author:** ![Daniel\_Robertson](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@Daniel\_Robertson](https://community.make.com/u/Daniel_Robertson)\
**Post date:** [October 26, 2022, 1:06pm UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/12 "2022-10-26T13:06:18Z")

</div>

You’re right, it is! Not the most obvious solution though. Perhaps it’s just me but I’d have thought that anyone coming from a coding background would anticipate arrays can be indexed with `[]`. I realise Make is a ‘no/minimum-code’ platform, but it does seem that something rather simple has been made overly complex for the sake of not typing any code syntax.

It would be nice if the [Array functions](https://www.make.com/en/help/functions/array-functions) plainly stated how to index an array, given it’s a fundamental functionality of arrays.

But hey-ho, got there eventually 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![alex.newpath](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/alex.newpath/32/84_2.png) [@alex.newpath](https://community.make.com/u/alex.newpath)\
**Post date:** [October 26, 2022, 2:57pm UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/13 "2022-10-26T14:57:41Z")

</div>

> [@Daniel\_Robertson](#):
>
> It would be nice if the [Array functions](https://www.make.com/en/help/functions/array-functions) plainly stated how to index an array, given it’s a fundamental functionality of arrays.

The documentation needs a ton of work. I hear it’s coming. It’s the only really weak part of make to be honest.

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [September 7, 2023, 2:55pm UTC](https://community.make.com/t/array-indexing-within-set-variable-module/4802/14 "2023-09-07T14:55:00Z")

</div>

This topic was automatically closed because it's resolved or inactive. Please, start a new topic.


