Is there a way to display a related table but have the records grouped by a columns value and totals summed? Something like this for a specific item (Items.ID)?:
SELECT SUM(Quantity), Location
FROM InventoryLog
GROUP BY Location
ORDER BY Location
Hi @Jason808
For further question, please post in Q&A board, not Tips & Tricks ![]()
-
Letās assume you have in your related table, a column named [parentColumnRef] with type Ref, with its source table being your current table ( assumption: PRODUCT or something like that?)
-
Create a slice of the related table - letās name it āmyChildrenSliceā (assumption: āInventoryLogSliceā)
-
in your parent table, create a virtual column - letās name it [_related_children_slice] with this expression:
REF_ROWS("myChildrenSlice", "parentColumnRef")
assumption:
REF_ROWS("inventoryLogSlice", "Product")
- create a view based on āmyChildrenSliceā, with:
-
view type Table
-
groupby: Location, Ascending (or Descending)
-
group aggregate: SUM:Quantity
- Eventually, you can hide the previously existing āRelated Inventory Logsā that you may have, at disabling its SHOW property.
Thank you for your reply and I will try to be more careful with where I post, need to learn this forum interface besides appsheet ![]()
I believe I was able to get this to work kind of natively, just selecting the group by and aggregate option but the problem is it still shows all the detail records. Iām sorry I didnāt mention this, was hoping the SQL query would speak for itself. Iād like the related view to show for each item:
Location Name Quantity
Location1 10
Location2 0
Location3 2
Location4 19
Without showing the eventual hundreds or thousands of records that make up the result as it would require a ton of scrolling to get to the next locationās totals.
I ran through the instructions above and it showed the same result with the detail records. Iām trying to suppress all the detail records from showing but havenāt figured out a way to do so. I did see a post about a pdf and using <<START but not sure how to work it into a related view. Thank you.
Thanks that did wonders for the View. I still donāt know how to get it to show as an inline view as a related item on the main Items view. With the system generated InventoryLog_Inline I was able to adjust the grouping and sorting to work EXCEPT for the changes _RowNumber is supposed to modify.
Maybe itās not possible to show a related summary without details, without clicking the āViewā button?
Please post screenshots of the inline view as shown in the app and of the view itself youāre configuring.
Iāve never tried this before and this behavior comes as a surprise. Looks like itās not going to allow it.
I was unable to attach the image of my view setup after several tries. I am grouping by location id and _row number, group aggregate being SUM::Amount. Like I mentioned, the view looks great. Current workaround is to teach the users to click the VIEW button. Iām going to use the default generated inline view to simplify it. I love that grouping by _RowNumber almost solves it. (thought it might make more sense for them to have an option in the group by to show or suppress detail records). OK to mark_RowNumber as the solution as it is the closest I am probably going to get?
Iād say so, yep.





