Need to count cells >0 from multiple tables and display Total Count

Avatar

Avatar

lisab73316618

Avatar

lisab73316618

lisab73316618

22-11-2017

I created a performance evaluation form that has multiple tables (6) (all have two columns with the last row/column of each table a total of possible points for that section).

At the end of the form I want to be able to count all the 2nd columns (not the totals)  that are >0 and display that number.

Any help would be greatly appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Magus069

MVP

Avatar

Magus069

MVP

Magus069
MVP

28-11-2017

Simply do a verification that values are greater than 0 each..

Answers (8)

Answers (8)

Avatar

Avatar

_Bruce_Robertson

MVP

Avatar

_Bruce_Robertson

MVP

_Bruce_Robertson
MVP

26-11-2017

Hi,

You can get a count of number of cells with a value greater than zero with an expression like;

Table1.resolveNodes("Row1.[NumericField1 > 0]").length

This assumes the second column is called NumericField1, and the table is called Table1 and the row called Row1 ... so you will probably have to change those.

You could have six expressions like this one in the calculate event of the you total field and add them together.

Regards

Bruce

Avatar

Avatar

lisab73316618

Avatar

lisab73316618

lisab73316618

28-11-2017

That worked!  I have been struggling with this form for days...  Thank you so much!

Avatar

Avatar

lisab73316618

Avatar

lisab73316618

lisab73316618

28-11-2017

I tried the following but maybe I'm missing something. (both fields could be blank at some point until the user starts filling in the blanks.

I googled this to get rid of my zero division  and I do get the calculation but I want to get rid of the error message.

Do I need another if statement? and how would I do that?

if(HasValue(Row2.RawCount&Row2.RawCount>0)) then (Row2.RawCount/Row3.Avail) else null endif

Avatar

Avatar

Magus069

MVP

Avatar

Magus069

MVP

Magus069
MVP

28-11-2017

Hi there,

it seems like one of those value are equal to 0.

You cannot divide a value by 0, so unless you make an if statement to make sure none of these values are equal to 0 you might get that message often.

Hope this help!

Avatar

Avatar

lisab73316618

Avatar

lisab73316618

lisab73316618

27-11-2017

I forgot to add that the Raw and Avail cells are calculated if that makes a difference.  Thanks.

Avatar

Avatar

lisab73316618

Avatar

lisab73316618

lisab73316618

27-11-2017

Bruce,

I'm sure that would work but I couldn't get it to with my limited knowledge.  However after poking around, I did get an if statement to calculate each table for me and then I used sum to add each to get to my total count.  Probably the long way around but it works.  Here's my next question if you can help.

I want to take the sum (Raw) and divide by the  Count (Avail) to get a Score.  I thought that was pretty simple but I get the following error using this.   - but it still gives me the correct answer. I would like to get rid of this error box.  Any help would be great.

form1.Subform9.Table7.Row4.Score::calculate - (FormCalc, client)

Score = Row2.Raw / Row3.Avail

1359533_pastedImage_2.png

Avatar

Avatar

lisab73316618

Avatar

lisab73316618

lisab73316618

23-11-2017

I'm sorry.  I am quite the novice with LC.  Can you give me more info or an example of an if statement that counts?

Avatar

Avatar

MinusZero

Avatar

MinusZero

MinusZero

23-11-2017

You will need to use a global variable to count the items that meet your 'if' logic and then display it in a textfield.