@Anonymous
You zeroed in on Tylenol, but my guess is that you need this for all the medicines.
Luckily you are not writing code as PowerApps is a no-code platform, so, you just need to devise the datashaping and evaluation formulas to return what you want.
You didn't really mention the resulting record you wanted from the 3 tables, so there are a LOT of ways to produce results.
In the below example, I took the approach of a record that has a column with the Medicine name in it, and then a column that has a table of the locations and their most recent date and amount.
So, the formula for that would be:
ForAll(
GroupBy(TRANSACTIONS,
"MedID", "_data"
),
{Medicine: LookUp(MEDICINE, ID=MedID, Medicine),
Locations:
ForAll(
GroupBy(_data, "LocID", "_records"),
With({_items: Sort(_records, Effective, Descending)},
{Location: LookUp(LOCATIONS, ID=LocID, Location),
Amount: First(_items).Amount,
Effective: First(_items).Effective
}
)
)
}
)
As mentioned, this gives you a record with a Medicine column. Then a Locations column that has a table with records of the Location name, the most recent date, and the most recent amount.
I hope this is helpful for you.