How to do Vlookup

Hi -

I was surprised to search and find no results for vlookup. This is a super common “programming” function in Excel so I figured there must be a thunkable equivalent. Can someone assist how to do this?

In Excel (in case you don’t know)
In Excel the function works like this. I have 2 columns. In the first column could be, for example, a list of the 50 states. In the second column would be their corresponding capitals. So when I input “Delaware” into the vlookup, it finds Delaware and returns “Dover”. This is an overly simplistic example, but, you get the idea.

Just not sure how to proceed and because my game was first built in excel … I’ll have to convert a lot of vlookups into thunkable code.

If you use TinyDb you can use State as key and Capital as value so when you use a Get block using a State as key you will find the Capital.

Thanks Giorgio, if I can ask a follow up question: is there a way to work with more than 1 value? Like in the previous example if we have Stats, Capitals, and a 3rd data point called “Population”. I can either input Delaware and get the capital, or input Delaware and get the Population. I could certainly use 2 TinyDB. Just wondering if there’s a way to consolidate.

I ask, because what I’ve worked on would be like one key, but 10+ values. So parts of the game say, “find this and give me the value in column 7” other parts say “give me the value in column 3”. It just simplifies things if I can use 1 big table.

If not I certainly can use multiple TinyDB - just curious if you know of a method to keep the data together. Thanks again!

I think you can use a spreadsheet instead of TinyDB. Spreadsheets are like excel (excel is a spreadsheet) so you can navigate beetween columns. Take a look to documentation and do a search on community to have some tips.

If you prefer to use TinyDB (as me), you can store as value a list of values so when you search for State you get a list and you know that first element is Capital, second is Population and so on and you can get the value you need.
Take a look to:
http://community.thunkable.com/t/tinydb-advanced-use/14700

Perfect - thanks! I hadn’t realized you can store lists in TinyDB. Thanks again Giorgio!

1 Like

please check my post.
http://community.thunkable.com/t/vlookup-procedure/34430

hi @Clayton_Brown,

I just wrote a post about doing this in Thunkable X - I don’t know if you’re still looking for this, but hopefully it will help others out in the future: