Performing a VLOOKUP in LocalDB


#1

One of the most powerful features in Thunkable is the new LocalDB component, which allows you to insert a mini-spreadsheet directly into your app. This might be the first of a larger series of tutorials mimicking features found in other spreadsheets, but for now let’s get started with VLOOKUP.

:question: What is VLOOKUP?

A VLOOKUP, or vertical lookup, allows you to search vertically down through a column of data and then find a corresponding value in your target row

:art: Design

Let’s start by adding a ListViewer with three items:
22

Next, in our LocalDB, we’ll create a 12 x 2 spreadsheet. Note that the “numbers” column has the same data as our ListViewer
59

:computer: Blocks

In our blocks, the “sublist” variable will contain the selection of letters we want from the larger list of letters. I’ve also created an “index” variable to make it easier to keep track of where we are in our loop. NOTE: The index variable should be reset to 0. I’ve amended this in the remix-able project below
33

When the user clicks on an item in the the ListView (which will be either “one”, “two”, or “three”) we start by clearing out the sublist, and resetting the index:
40

The next thing we want to do is set up our loop, moving vertically through the data in the “numbers” column. After each pass through the loop we manually increment the “index” variable and when we reach the end of the loop we display the sublist in a label
58

Finally, we need to check whether or not a letter should be added to the sublist. To do this we compare the ListViewer item (called item) to the Loop item (called j). Now, using our index variable we can fetch the corresponding value from the numbers column.

:gift: Remix

If you want to take a closer look at my app or use this feature in your own app you can remix my project here.


How to do Vlookup
Search & Filter LocalDB
Spreadsheets connected to FREE databases (airtable is not free)