Fetching data from Google Sheet based on user selection

Hi - new here :slight_smile:

I am looking to build a customer KYC/AML risk rating app.

I would like to fetch an integer value from my Google Sheet based on the user selection of a drop down in my app like:

If select1="NGO" then look for "NGO" in my sheet and return the value in the next column. This would be a rating between 1 and 5.

So far I have got to showing the user select as a label but I need to build on this by showing the rating of that selection...

Any help would be appreciated.

Hey @bridgid!

I'm not actually seeing an endpoint in the Google Sheets API that allows for searching by cell contents which makes this a little tricky. I might be missing something, but if that is indeed the case you might need to do the actual searching in the frontend. You can do this using something like

const rowToFind = query1.data.find(row => row.type === select1.value);
return rowToFind.rating;

or, with a one-liner like {{ query1.data.find(row => row.type === select1.value).rating }}.

The trouble is that this would require you to have the full data set you'd be searching in the frontend. How many rows would you actually need to search through? Is your data set up in a way that you might be able to only search in a specified range within your Google Sheet and still get all the results you need?