How to get an item from different table based on Key1 = Value2

Very new to this…hope this makes sense.

I have two tables being called into the app: userstable and gametable.

usertable has schema (name, g1, g2, g3)

Name g1 g2 g3
Phil yes no no

gametable has schema (gameid, date, game)

gameid date game
g1 oct 3 checkers
g2 oct 5 chess
g3 oct 7 cards

On one of the app screens, I want to list all the games (repeated data variable pulled from gametable) but with the values from usertable based on logged in user.

Oct. 3 - checkers - yes
Oct. 5 - chess - no
Oct. 8 - cards - no

So on the repeat value for the yes/no, I need a formula like the following:

data.usertable.(data.gametable.gameid) which would go through data.usertable.g1, data.usertable.g2, and data.usertable.g3

How do I get the gameid within this formula? Does this make sense? Thanks

Hi, I would suggest you MAP (docs) the gametable so that for each game you add a new “status” field using SET_KEY (docs).

To find the right status, you can use LOOKUP (docs) to find the status of the game from the object in usertable.

To find this object you can use FIND_BY_KEY(data.usertable, "name", "Phil") (replacing “Phil” with the variable where you store the current user’s name.

So something like

MAP<game>(data.gametable, SET_KEY(game, "status", LOOKUP(FIND_BY_KEY(data.usertable, "name", "Phil"), game.gameid)))

You. Are. The. Best!! Thank you so much for taking the time to respond…it works perfectly.

1 Like