Writing Aggregate of Child's Total to a column in Mother Table

Hey All,

I am just a beginner in AppSheet and I find it very exciting to create simple apps to collect data using mobile devices.

I have a table named Recipe_Header where I keep the recipe info and another table named Recipe_Detail where I keep recipe details. There is a mother to child relationship where there are multiple rows in the Recipe_Detail corresponding to the Recipe_header table where Recipe_Header.ID is the common field linking both tables.

On the Recipe_Detail I have a column (Cost) where I calculate the total of each row. In the Recipe_Header I also have a column (Recipe Cost). I would like to take a total of related Recipe_detail lines’ (Cost) column and store it in the (Recipe Cost) column of Recipe_Header. I could manage to create a virtual column that does the calculation on the Recipe_Header table however, I could not store this data on the table itself.

Any contributions to the solution is much appreciated.

Cheers,

Neşet

Welcome to the AppSheet community.

I believe you could implement the intended behavior by using reference actions. A sample app below shows updating child table real columns with an action on parent table. In your case it will be the other direction- update / addition in child record to update the parent.

https://www.appsheet.com/samples/This-app-shows-how-to-use-reference-actions?appGuidString=e76d2e73-3d26-475c-a8f8-9911f5015920

The reference action could then be set as an event action on child record form save.

2 Likes

@Neset_Kutlug
You need to add an extra physical column in your Recipe_Header table. Calculations inside the virtual columns, cannot be recorded to the sheet, they can be viewed from the app only.

2 Likes

Thanks Suvrutt. I will be looking into it as per your suggestions.

1 Like

Thanks a lot Levent. I do have a physical column in my Recipe_Header.

1 Like

Provided you have a physical column for recording that cost that in your Recipe_Header table, than the AppFormula for this column should be able to record that value to the sheet.

2 Likes

Thanks I will first try to grasp what Suvrutt has proposed which at first glance makes some sense with my limited knowledge of AppSheet. The column I will be updating will be the column named (Recipe Cost) in my Recipe_Header table. Cheers

1 Like

@Neset_Kutlug
Provided you can add levent@able3ventures.com as a co-author to your app and share the gsheet as well with edit access, I can check if you somehow struggle getting a satisfactory result.

1 Like