I have a fitness app in appsheet
I have a table named Nutrition with columns -- Nutrition Item, Serving Size, Serving Measurement, Calories, Fat (g), Carbs (g), Protein (g)
I have another tabled named Daily Diet with columns -- Key, Date, Nutrition Item, Servings
In a UI form to capture Daily Diet, I want to be able to select a Nutrition Item from a dropdown and when I do the corresponding Serving Size + Serving Measurement display as a text description.
For example, if I select Nutrition Item "Strawberry", I want to see "Serving: 1 Cup(s)" as a description (as 1 Cup is the Serving Size for Strawberries, specifically).
This seems simple, but I have no idea how to do this. Is this a Reference, Select, Lookup... something else?
Thanks
Create a virtual column with an expression like below and make this the label of the table
"Serving: " & [Serving Size] & " " & [Serving Measurement]
Thanks, but I am not sure what you mean here. I have had to create virtual columns that display dependent upon what I select.
SELECT(Nutrition[Serving Size], ([Nutrition Item] = [_THISROW].[Nutrition Item]))
and
SELECT(Nutrition[Serving Measurement], ([Nutrition Item] = [_THISROW].[Nutrition Item]))
I wonder if there is a way to have 1 virtual column "concatenate" those.
The vc should be created in Nutrition table and set as label.
You can create a ref col in Daily Diet to Nutrition table and the dropdown will show the text you are seeking.
I use a virtual column for something like this, I have a members enumlist (where I list all members from the table) for each chosen member it will show all their details below
SELECT(Users[UserID],IN([UserID],[_THISROW].[Members Related to Case]))
Select(NUTRITION[ITEMID],IN([ITEMDID],[_THISROW].[NUTRITIONITEM]))
This is what it looks like in practice
This roughly worked. I had to make two virtual columns with a Select() for each, as follows:
SELECT(Nutrition[Serving Size], ([Nutrition Item] = [_THISROW].[Nutrition Item]))
SELECT(Nutrition[Serving Measurement], ([Nutrition Item] = [_THISROW].[Nutrition Item]))
The problem now is that for the Serving Size, it will only display a whole number as opposed to a decimal. So, if a Serving Size is 0.25, it shows as 0. It automatically sets that column to "List" type. When I change it to "Decimal", I receive an error--
"Column Name 'Serving Size' in Schema 'Daily Nutrition_Schema' of Column Type 'Decimal' has an invalid app formula '=SELECT(Nutrition[Serving Size], ([Nutrition Item] = [_THISROW].[Nutrition Item]))'. The type of the app formula 'List of Number' does not match the column type 'Decimal'."
User | Count |
---|---|
43 | |
27 | |
23 | |
16 | |
12 |