[solved] FOR EACH ITEM J IN LIST with GoogleSheet

Hello, guys.

I have a list L with a lot of rows, for each row there’s an ID number, which its index is 1.
I’m trying to make the blocks read my sheet from google spreadsheets and sum the occurrences for a given ID. IT’S NOT WORKING…

For example:

L:[ID,store,location,earning]

L: [[01, mcdonalds, NY, 340.00],
[01, mcdonalds, NY, 198.65],
[02, bobs, FL, 159.35],
[03, hershey, PA, 1895.56],
[03, hershey, PA, 195.98],
[03, hershey, PA, 1175.45],
[02, bobs, FL, 1832.35]]

ID = 03
count: 0

for row in L:
if row[1] == ID:
count = count + 1
print(count)

#the result would be 3 because there’s 3 occurrences of ID as 03.

It’s so much easier to do this with a formula in Google Sheets and then get the value from the cell containing that formula.

The variable block youre using is just changing the name of the variable not the data. Use the set block ive shown and see if that solves your issue.
temp2

Thanks for taking a time out and reply me!

You’re fully right. I’m highly considering it, even tho I could solve my problem.
I guess it’ll save me some time haha

Thanks for helping!!

Your comment made a lot of difference to me. Even tho i couldnt solve the problem with it, it helped me to solve a problem I didnt know existed.

What got me is that the global variable “app variable index” wasnt adding up the numbers, then i changed it to the own variable that was receiveng the data and it worked.

1 Like

Glad you got it working. Good luck!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.