Lookup Another Table
Let’s write one of the most common formulas — performing a lookup to another table.
XLOOKUP
The function for performing a lookup in Tabmega is XLOOKUP. Excel and Google Sheets have several ways of performing lookups, including VLOOKUP
, INDEX/MATCH
, and more recently the XLOOKUP
function. Once Excel users learn the XLOOKUP
function they usually find it the easiest and most intuitive way of performing lookups. See this Reddit thread for proof. As a result, Tabmega only supports XLOOKUP
so users only need to worry about learning one lookup method instead of three.
Performing lookups
-
If you are following along with the MovieLens 25M dataset from the Tutorial Setup, go to the ratings table. Click on the column to the far right with the + button. If you like using the keyboard instead of the mouse, you can navigate to the button with the arrow keys and it will have the same effect.
-
Name the new column
movieTitle
. -
Start editing the formula for the cell in row 1. The beginning of the formula will be
=XLOOKUP(
. Feel free to use the autocomplete. -
For the first argumnet, Use the mouse or keyboard to select the
movieId
column as the first argument. -
Add a
,
to start the second argument. Use the mouse or keyboard to select themovieId
column in the movies table. This requires switching tabs while editing the formula. If you like Keyboard Shortcuts for switching tabs, they are the same as Excel and Google Sheets. -
Add a
,
to start the third argument. For the third argument, use the mouse or keyboard to select thetitle
column in the movies table. -
Hit the Enter key to finish the formula and get ready to apply.
-
Click the Apply button. This lookup calculation may take a few seconds depending on your computer. You’ll see the Processing dialog while it’s running.
-
Perform the same steps as above to add a new column that’s a lookup to the
is comedy?
column that we calculated in Add Columns and Formulas usingmovieId
again. The end result should look like below.
Hint: the formula you’ll want is =XLOOKUP(ratings.movieId, movies.movieId, movies.'is comedy?')