Iterate through two google sheets columns at once?

i have a google sheet that is displaying this data:

i am trying to get the “bad”, “good”, etc labels to display from the row the student id and class hour is in.

for example, the specific student id shown has a total of 12 "Bad"s in 1st Hour.

i’m trying to see if i can display 12 in a label.

these are the blocks i have set up so far, but there’s nothing displaying in the app:


is there a better way to reformat this double loop situation? i feel like there is, but i’m not sure what.

As a teacher, I really hope you’re not keeping a spreadsheet of “very bad” results from students. Just labeling it that way worries me. I don’t know if this is behavioral or academic but either way surely there are other ways to keep track of their progress.

Your mood period function is very complex. It can be simplified. As it is, it seems that you are trying to find a time when the Student ID equals the Class Hour, which won’t ever happen.

Can you give a detailed, clear example of the input (which you’ve shown) and the search process? Just an algorithm… what are the steps for that?

For example:

  1. Given a student ID, find the rows with that ID
  2. For each row that matches that student ID, add up the “Bad” column values.
    etc.

Because if all you need to do is to display 12 for the first student ID shown, you can achieve that with a VLOOKUP (search the forums). That can be as simple as using the find first occurrence of block to determine the row # and then using that result to get the value of the “Bad” column.

oh no worries! this is a mood tracker, so the “very bad” in this case would be that they’re in a “very bad” mood.

this is the example i’ve written in psuedocode, which is as clear as i can make it:

for each item in the column of student ids
      if the student id in the column matches the student id of the logged in student
          then do: for each item in the column of class hours
                     if the class hour is equal to the current hour of the day
                       display each number from bad, good, okay, very bad, and very good
                         break out of the loop

Okay so would this be another way to say it?

Display the value of the “Bad” column for the logged in student at the current time (hour)

And then for each other column (“Good”, “Okay”, etc.)?

The way I would do that is to Find the First Occurrence of app variable Student ID in column “Student ID” of the data source (that will return the row # with Class Hour “1st”) and then add [current hour minus one] to that value. Use that number as the row id to get the row object from the data source. Then get each property (column name) from the row object.

·····················································································································
Need help? How to Ask Great Questions :sparkles: Debugging A Project :sparkles: API JSON Tutorial

Want to hire a Certified Thunkable Expert? Elevate your app with Tatiang on Fiverr