Search code examples
relational-databasepowerapps

PowerApps merge related tables


I'm new to PowerApps and am exploring relational databases before starting a project in PowerApps (involving relational databases). I'm trying to do a simple join of two entities (drink and human), where the drink has a BuyerID field which relates to a "human"'s Primary ID. So I tried ForAll(Filter(drink, (name = "Americano") And (drink.BuyerID = human.PrimaryId) ), Collect(AmericanoDrinkers, {FirstName: human.firstName, LastName: human.lastName})) to get a collection of humans who brought an Americano, but I get an Invalid argument type error with drink.BuyerID = human.PrimaryId. Any ideas? I've tried changing = to in and stuff like drink.BuyerID to drink[@BuyerID]. Note that the drink.BuyerID datatype is "Lookup" and human.PrimaryId is integer, so could I be getting this error because of the different types? Also I'm certain there's nothing wrong with the data because when editting the drink entity in excel, the powerapps add-on shows the related humans when a BuyerID is selected.


Solution

  • The problem was just the setup, I just created a new field (BuyerID2) in the drinks entity and set it as a number value rather than a lookup like BuyerID was, and all 3 (my initial one, and the two Meneghino provided) solutions worked fine (although I had to change drink.BuyerID = human.PrimaryId to BuyerID2 in human.PrimaryId).