# Design guidance needed

**URL:** <https://forum.inductiveautomation.com/t/design-guidance-needed/14245>\
**Category:** Ignition\
**Created:** [May 9, 2017, 6:59pm UTC](https://forum.inductiveautomation.com/t/design-guidance-needed/14245 "2017-05-09T18:59:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Micky.Franks](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Micky.Franks](https://forum.inductiveautomation.com/u/Micky.Franks)\
**Post date:** [May 9, 2017, 6:59pm UTC](https://forum.inductiveautomation.com/t/design-guidance-needed/14245/1 "2017-05-09T18:59:41Z")

</div>

I am working on building some screens to view inventory in rice bins. Each bin can hold from 1 - 30 loads. Each load has a moisture value that we track when transferred to the bin. I am trying to figure the best way to be able to log each loads moisture value going into a bin and be able display an average moisture of the bin. These values are entered manually not OPC values. What is the most effieceint way to set things up get the average and ignore the values as zero? I tried using MySql but I would then need to transpose the data to get averages. I tried creating tags for each load but writing an expression to calculate the average and ignoring zero gets hairy. Just looking for other suggestions or ideas I may be overlooking.

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/707adbb8d6ba60ddb3652edd116b064f41682a8a.png)

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/0f73c5b1b11f2d091a09fb7b98dfa9a8a528c6c8.png)

---

<div class="post-metadata">

**Author:** ![heybales](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/heybales/32/3358_2.png) [@heybales](https://forum.inductiveautomation.com/u/heybales)\
**Post date:** [May 9, 2017, 9:58pm UTC](https://forum.inductiveautomation.com/t/design-guidance-needed/14245/2 "2017-05-09T21:58:46Z")

</div>

I would use a dataset to hold the data for each load, and a table to display the current loads.

You could allow data entry below the table for new loads with an Add button that appended a row to the dataset.

Then create an Average tag with an expression to calculate the average. Use the sum function, and divide by data.rowCount.

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [May 10, 2017, 1:00am UTC](https://forum.inductiveautomation.com/t/design-guidance-needed/14245/3 "2017-05-10T01:00:24Z")

</div>

Do you need to go back and look at when these loads were put into the system? If so, I would look at storing this in a database table. Also it would be easy to query the results out of the table and use a python script to cull out the zero values and only run an avg on the values that arent zero. If you have no need to store this data historically it would be fine to use a dataset.

---

<div class="post-metadata">

**Author:** ![martinel3746](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@martinel3746](https://forum.inductiveautomation.com/u/martinel3746)\
**Post date:** [May 11, 2017, 8:40pm UTC](https://forum.inductiveautomation.com/t/design-guidance-needed/14245/4 "2017-05-11T20:40:27Z")

</div>

If the table/tag layout is consistent, you can use a loop to skip through columns with a Range.  
\_\_\_for cellValue in range(2,30,2):  
\_\_\_\_\_\_#check values and calculate average.

I’m a database guy so if I were reading non-normalized data in a table, something like this would work:  
resultSet = system.dataset.toDataSet(system.db.runQuery( sql, db ))  
cols = system.dataset.getColumnHeaders(resultSet)  
moistureCount = 0  
moistureSum = 0  
for row in range(resultSet.rowCount):  
\_\_for colName in cols:  
\_\_\_\_if colName.find(‘moist’) \> 0:  
\_\_\_\_moisture = resultSet.getValueAt(0,colName)  
\_\_\_\_if moisture \> 0:  
\_\_\_\_\_\_moistureCount = moistureCount + 1  
\_\_\_\_\_\_moistureSum = resultSet.getValueAt(0,colName)

---

<div class="post-metadata">

**Author:** ![Micky.Franks](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Micky.Franks](https://forum.inductiveautomation.com/u/Micky.Franks)\
**Post date:** [June 13, 2017, 6:54pm UTC](https://forum.inductiveautomation.com/t/design-guidance-needed/14245/5 "2017-06-13T18:54:58Z")

</div>

I ended up creating screens to have operators enter the data into a database that was pretty much how I needed to extract it out.
