I have 3 relevant tables:
Breweries are independent entities. Every entry in the Beers list has a BreweryID. Every entry in the Tastings list has a BeerID.
Beers and Breweries have Related virtual columns automatically thanks to the direct reference between the BeerID and the BreweryID. What Iโd like is a Related Tastings at the Brewery level, so when someone is in the Brewery context, they have two Related sections - Related Beers and Related Tastings.
Thanks for any help you can provide!
Solved! Go to Solution.
1000%.
I agree with this. I guess I saw you were new to the Community so just assumed you were just beginning the app.
So how to get Related Tastings? If I understand this part of your data structure, Tasting rows are indirectly related to a brewery through Beers. We just need to โconnect the dotsโ!
An expressionl ike this should do it:
SELECT(Tastings[TastingID],
IN([BeerID],
SELECT(Beers[BeerID], [Brewery ID] = [_THISROW].[BreweryID])))
Carry your Brewery ID into the Tastings table. AppSheet will automatically provide a Related Tastings virtual column.
How?
I shouldnโt copy the brewery actually into the Tastings table because itโs duplicating data in a database.
I tried adding a virtual column to Tastings with the following formula (just taking a stab at it) but the column doesnโt end up having any data in it:
SELECT(Beers[BreweryID], Tastings[BeerID] = Beers[BeerID])
This is a common misnomer. It is perfectly fine, and even preferred in some instances, to copy certain data elements to make implementation and/or viewing of the data easier.
However, as I think about your use case, Tastings probably should be a child table of the Breweries table anyway. At least the way I think of it, a Tasting is an event at a Brewery. I would go to the event and be presented several Beers to try.
Soโฆadd the Brewery ID to the Tastings table and make Tastings a child of Breweries table. You will get the Related Tastings list you want.
I guess I donโt entirely agree here, but itโs probably a little bit of an app usage question. A tasting - in this context - is any sampling of a beer, at a brewery or not (e.g. bottles at home). A brewery is a property of a beer, it has nothing to do with the tasting event.
But in any event, this app is supporting about 5k lines of historical data so Iโd rather not revamp my data structure just for this purpose if thereโs a way I can gather this data through an expression - which it seems like I should be able to do.
I do really appreciate your feedback on duplicating data across tables, though, and I will consider that in future planning.
1000%.
I agree with this. I guess I saw you were new to the Community so just assumed you were just beginning the app.
So how to get Related Tastings? If I understand this part of your data structure, Tasting rows are indirectly related to a brewery through Beers. We just need to โconnect the dotsโ!
An expressionl ike this should do it:
SELECT(Tastings[TastingID],
IN([BeerID],
SELECT(Beers[BeerID], [Brewery ID] = [_THISROW].[BreweryID])))
Youโre a champ! Itโs the IN statement that I was missing when I was trying to write my queries to pull this data. I was trying to connect the dots but never getting it quite right. This works perfectly, thank you so much for both the time discussing it, and the solution.
User | Count |
---|---|
44 | |
31 | |
29 | |
14 | |
14 |