Counting array items

Hello Everyone,
I have a google sheets that lists students and their classes (class A, Class B, and Class C). The goal is to create a document that fills in all of their info onto a template. I’ve figured out to do all of that but i need to include the number of students listed on each document which i could do if i could count the amount of arrays that go through. the answer to this question is the closest that i’ve been able to find to solve my problem but i can’t figure out how to connect it to the info that has been recieved from the google sheet to actually count the arrays.

Here are some photos that explain what i have right now
Overview:

Filter to module 143 contains arrays 1-9 and to module 149 contains arrays 10-18

What the sheet looks like

If I understood your question you want to have a count of the number of students in each Class?

If this is the case, here are some options:

  1. Use the map function to extract all the instances of Class = Class A. This would look like this: map(Array;key;Class;ClassA). The last step would be to apply the length() IML function around the above map function. Then you would need to do this for each Class you are interested in.

Note that you would need to dynamically map the array, and then statically map the remaining parts of the function (everything after the first semicolon). In these static mappings you need to use the ‘raw’ value from your array. You can find this by either downloading the output (top right) or hovering over the field you care about.
Screenshot 2024-01-05 at 3.38.18 PM

  1. Group your array by Class.

Then you would use the length of array from each bundle as the amount of students in that Class

Let me know if this helps.

2 Likes

Thank you for your response @IOA_Harman . I’m just not sure where to start. Where would i be putting the map(Array;key;Class;ClassA). I’m also not sure how to get to the step where the json gives me the raw: itemcode options