Running Total for Samples


I have two spreadsheets that are related to each other. The delineatedLocations spreadsheet enumerates items and groups them together by the key value in Clipboards.

This means that locations will be grouped together, for example, by key “123” and all show up under the Clipboard 123.

I have a third table named Routes where I want to keep track of the Running Total for Samples in delineated locations. So I tried writing this expression to count how many samples in delineatedLocations correspond to each clipboard:

select(routesV7[Running Total for Samples],delineatedLocationsV7[Order]=clipboardsV6[key])

But this expression sums the samples in every single clipboard. Every route has at least one clipboard and I want the “Running Total for Samples” column to for every route to count all the samples in all the clipboards in all the locations for that route, not all of the samples for every single location in the app.

Does my explanation make sense?

I have three separate tables with parent-child relationships and I want the samples in the grandchild table counted properly so that it corresponds to the correct parent and grandparent tables.

Hi @tvinci. You might want to take a look at this sample app. It shows how to do something similar for a simple dataset:

Your expression looks a little funny to me. When you write delineatedLocationsV7[Order] that evaluates to the entire list of values from your Order column. Same for clipboardsV6[key].

A common pattern for select expressions is something like this: SELECT(Other Table[Column], [_THISROW].[Column from current table] = [Column from other table]).

1 Like

Thanks @tony

Since there are 3 tables in question which would be the “Other Table” and which would be the “Current Table?”

The current table is the one where you want the total displayed. The other table has the related records that you want to count.

I don’t follow your scenario exactly, but the most common case is an Order with Line Items. You get the total for the order by summing over the related line items.

Most of the time, the relationship between the tables is made explicit via a Ref column. See the Order/OrderDetails table in this example and how the total is calculated: