 Level 1

0% to Level 2

Tip /

to gain points, level up, and earn exciting badges like the new
Mission!

View all

## Formula that looks at two different fields  Level 2

Hi,

I posted this request for help not too long ago but didn't clearly explain what is needed.

When text is entered into a field (currentgoal1, currentgoal2 - each equaling 1), the formula needs to look at a different field (point1, point 2 - each holds a list box of with points 1, 3, 5, or NA) to see if "NA" was chosen.  If NA was chosen (rather than a point, 1, 3, 5) then the goalcount (total number of populated currentgoal fields) needs to subtract 1 from goalcount.

currentgoal 1 = 1 point

currentgoal 2 = 1 point

currentgoal 3 = NA

3 goals, 2 points, 1 point field with NA

Since one of the current goals is has a point of NA, the overall count of currentgoals in the goalcount field (total number of populated currentgoal fields) should state 2 with the totalpoints field (all points fields added together) stating 2.

How can the formula be adjusted to subtract a currentgoal with a chosen point of NA?

Formula used now for counting current goals:

goalcount = 0

!= null){

= goalcount + 1;

!= null){

= goalcount + 1;

(Table3.Row3.currentgoal3.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row4.currentgoal4.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row5.currentgoal5.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row6.currentgoal6.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row7.currentgoal7.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row8.currentgoal8.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row9.currentgoal9.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row10.currentgoal10.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row11.currentgoal11.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row12.currentgoal12.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row13.currentgoal13.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row14.currentgoal14.rawValue

!= null){

= goalcount + 1;

if

(Table3.Row15.currentgoal15.rawValue

!= null){

= goalcount + 1;

= goalcount;

}

this.rawValue

goalcount

}

goalcount

}

goalcount

}

goalcount

}

goalcount

}

goalcount

}

goalcount

}

goalcount

}

goalcount

}

goalcount

}

goalcount

}

goalcount

}

goalcount

if

}

goalcount

(Table3.Row2.currentgoal2.rawValue

if

}

goalcount

(Table3.Row1.currentgoal1.rawValue

if

var

2 Replies  Level 4

For sake of maintainability and readability, give all your fields the same name and put each currentgoal and goal field into a subform. Repeat the subform n times (13?) , then:

1) Create a list of all subforms using xfa.resolveNodes

2) Traverse the list using a for-loop. If currentgoal.rawValue is not NA then increase goalcount and totalpoint.  Level 2

Sorry, I was trying to edit. Is this better?

var

goalcount = 0

if

(Table3.Row1.currentgoal1.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row2.currentgoal2.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row3.currentgoal3.rawValue

!= null){

goalcount

= goalcount + 1;

}

this.rawValue

= goalcount; 