Block - Calculate Total Using Select Type & Calculate Average

Question: How to sum all the scores, which is a select type, and divide to get the average? if select NA is not to be calculated.
For Example, I have 3 table lines the option I select is 1,0.5 and NA.
so,
Total = 1.5
Average = total / 2 table lines (exclude NA line)
= 1.5/2
= 0.75

Calculate Total Using Select Type

Let me show you how to do it in the Automation block.

  1. Go to the Default form

  2. Open and Scroll all the way and Click Add Automation

  3. Drag & Drop For block

  4. Input #Form#Table

  5. Input item under each

  6. Drag & Drop Condition block
    image

  7. Input #item#Attendance =='0.5’

#item#Attendance =='0.5' is True
  1. Drag & Drop Action block
    image

  2. Click +Add Action

  3. Select Set

  4. Variable: Input #item
    Value:
    * Click Expand Property
    * Select Total = 0.5

  5. Click +Add Action

  6. Select Set

  7. Variable: #Form #Total
    Value: sum(#Form#Table#Total)

#item#Attendance =='0.5' is False
  1. Drag & Drop Condition block
    image
  2. Input #item#Attendance =='1’
#item#Attendance =='1' is True
  1. Drag & Drop Action block
    image

  2. Click +Add Action

  3. Select Set

  4. Variable: Input #item
    Value:
    * Click Expand Property
    * Select Total = 1

  5. Click +Add Action

  6. Select Set

  7. Variable: #Form #Total
    Value: sum(#Form#Table#Total)

#item#Attendance =='1' is False
  1. Drag & Drop Action block
    image

  2. Click +Add Action

  3. Select Set

  4. Variable: Input #item
    Value:
    * Click Expand Property
    * Select Total = 0

Output to calculate Total from Select Type

CPT2205161520-1276x622

Calculate Average without N/A line

  1. Drag & Drop Condition block from the Start
    image
  2. Input #Form#Table.Count>0
#Form#Table.Count>0 is True
  1. Drag & Drop Action block
    image

  2. Click + Add Action

  3. Select Create

  4. Variable: totalNA
    Value: filter(#Form#Table#Attendance ==‘N/A’)

  5. Click + Add Action

  6. Select Create

  7. Variable: newLen
    Value: len(#Form#Table) - #totalNA.Count

  1. Drag & Drop For block
    image
  2. Input For: #Form#Table
    Input each: line
  3. Drag & Drop Condition block
    image
  4. Input #line#Attendance=='N/A’
#line#Attendance=='N/A' is True
  1. Drag & Drop Action block
    image

  2. Click +Add Action

  3. Variable: #Form#Average
    Value: #Form#Total / #newLen

  1. Drag & Drop Action block
    image

  2. Click +Add Action

  3. Variable: #Form#Average
    Value: **#Form#Total / len(#Form#Table)

Output to Calculate Average Without N/A row

Hnet.com-image (1)

what is that mean for step 5

I unable to find item.

Hi @janchinkhai item is a defined word. It means each row of the table. You may define any words as you wish.


it likes this o

oh, it needs to be small-cap. I will suggest tableRow


it just like this, I need the total score to be calculated.

Since Select is actually string and cannot sum up. In the table you need another column with type is Number to convert from String to Number. For example as below image