[Solved] Filtering data return only one results

HI EveryOne
I’m using the following blocks to filter data but it returns invalid results


when selectin the date 5-1-2024 it returns results from 5-12-2023
In Addition there is another variant of the block where it returns only the first result where actually there are many results that meet that criteria

I both cases I’m filtering data from on datasource to another to populate a data viewer list.

Your problem is the [gear] list block. Remove it. It’s almost always a bad idea to use it unless you’re initializing a list.

With it included, you’re creating a list of a list because the list of values block is already a list. This may be why you’re only getting one result. Your loop only has one item (a list of a list instead of a list of items).

An example is if your spreadsheet column contained:

apple
orange
lemon

Then the list of values block would create a list like this with three items:

{apple,orange,lemon}

But by adding the [gear] list block in front of that, it creates a list like this with only one item:

{{apple,orange,lemon}}

1 Like

@tatiang
Yes this did the job.

@tatiang
After removing the fear list block ,Now if there is a matching result this block returns all the items in the table


like this screenshot here
Screenshot 2023-12-17 195712

You may need to refresh the data viewer after your loop.

Can you post a link to your project?

Edit: actually, I see your mistake. For every iteration of the loop, you’re checking to see if the entire list contains the search term. Instead, you need to check if the item i equals the search term.

@tatiang
I tried this one but the problem still exists


Screenshot 2023-12-18 005608

Sorry, I was a little took quick in my explanation. You’re using i as the loop counter. So it doesn’t make sense to compare that to your search term (1=“Cola”?, 2=“Cola”?). You have to use the for each j in list block and compare j (the list item) to the search term.

@tatiang
I tried this one


I think this one works But it return empty rows.
Screenshot 2023-12-18 112405

The Arrows appear only if there is a match, but in case there is no match it didn’t appear.

The row id cannot be the value in j. So here’s the slightly tricky part: if you count with a loop variable that is an integer such as your earlier example with i, you can’t use that to search for a search terms. But if you use a string as in your example with j then that is not a valid row id.

My suggestion is to create a variable called app variable Row and set it to 0 before the for each item j in list loop and then within the loop, change its value by 1 before the if block. Then, if j=app variable Selected Date, you use app variable Row as the row id in your create row block.

1 Like