Display an average of table fields from a single entry?

Howdy! I’m making an app that user will use to check the build progression of various products that are in progress.
I have a table in which one line/entry represents a product on the manufacturing floor. Each of the fields seen represent the progress of each of its sub-assemblies. I want to display the average of all of those fields to in order to represent the total progress of the machine’s assembly.

This next image is the app page I’m working on. When a user selects a product from the list on the right (same table), I want it to display the machine’s total assembly progress on the left. This is the average I mentioned before.

Said second image:

Hey Dakota!

Thanks for asking your question to the Tulip Community and welcome :tada:

My first thought here is to use arrays and the expression editor. Here’s something I just tried:

On my sample table, I have 2 columns of data I want to average.

  1. I put a trigger on the table to save these values into a variable array.

  2. I made a button with a trigger where in the expression editor I calculate the average of that array with those numbers in it. Then, I clear the array so if I click on one record in the table, then another, the array clears and I can get the average just for each row selected (whereas, if I didn’t clear the array, the numbers would keep getting added as I select different rows and affect the average).

Does this help with your use case?

Yes, that worked, thank you!

1 Like

Awesome! Happy Tulip-ing :tulip: