How to return the value of a specific row from a Google Sheet

Im trying to query for a specific row in google sheets, and currently im using Query JSON with SQL as a resource. Here is what the data looks like in Google Sheets:
Screenshot 2024-09-23 at 5.17.36 PM

I want to be able to set a value to the value associated with variable c
Screenshot 2024-09-23 at 5.21.43 PM

Right now, the only way ive made it work is by using something like
{{ gsheet['2'].value }}, but i want it to depend on the variable name (since the gsheet order might eventually change, and i dont want it to depend on the index value, if that makes sense).

Hello @alessyl!

Since it appears that gsheet is an indexed array, you should be able to to return the necessary information by using a find() or filter() function of the array, possibly like:

gsheet.filter(row => row.value === 'c')[0]

depending on how you access the column data per row (I am unsure of the right syntax for the Gsheet query)

Appreciate the response! It doesnt look like filter() or find() are available functions for me to use (dynamicVariables is the gsheet resource im using)

Screenshot 2024-09-24 at 11.28.21 AM

Okay, so I'd need to see the query and its results to better understand what dynamicVariables is doing and returns.

Generally, if the query in your app is called dynamicVariables then its response would be usable as {{dyanmicVariables.data}}

If the query is already returning an array, then the data property here would be what you would be filtering, like:

{{dyanmicVariables.data.filter(x => x....)...}}

filter() and find() are member functions of any Array type. For example:

let array = [1,2,3,4,5]
let found = array.find(num => num == 5)
return found

Which should output the number 5:
image

1 Like

Hey @alessyl! Thanks for reaching out.

I had to do some testing because I haven't worked with the Google Sheets resource before, but it seems to return an object in the form of { index: { column_a: 'value_a', column_b: 'value_b' } }. This means that it's already well-formatted for querying with SQL.

The below configuration works for me:

image

Let me know if this setup is useful to your particular use case! I'm happy to answer any follow-up questions you might have, as well.