Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Formula

Avatar

Level 2

Hi,

I'm using Livecycle Designer for a dynamic form.  I have a section of a form that contains fields for the user to enter goals in one column and then choose a rate (0,1,2,3,NA) for that goal in another column.  There is a formula to add up the number of goals entered if the field has text in it.  There is a situation where the user will enter a goal but the chosen rate will be NA - meaning that there is a goal but its not applicable at this time.

If I have 3 goals entered, and one is rated NA with the others rated at 1 (goal one = 1 point, goal two = 1 point, goal three = NA), there will be three goals and only 2 points.  I need to have the goal listed but it can't be added into the total of goals field.

Goal 1 = 1 point

Goal 2 = 1 point

Goal 3 = NA

Total points = 2 with three goals would then be divided for an overall score.  Total points (2) divided by 3 goals = 0.67.  Problem is that the goal with a rate of NA can't be counted into the formula.  It should calculate as Total points (2) divided by 2 goals = 1.0.  The NA will not have a numeric value.

Current formula for adding goals is:

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;

}

if

(Table3.Row4.currentgoal4.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row5.currentgoal5.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row6.currentgoal6.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row7.currentgoal7.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row8.currentgoal8.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row9.currentgoal9.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row10.currentgoal10.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row11.currentgoal11.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row12.currentgoal12.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row13.currentgoal13.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row14.currentgoal14.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row15.currentgoal15.rawValue

!= null){

goalcount

= goalcount + 1;

}

this.rawValue

= goalcount;

3 Replies

Avatar

Level 5

Hi,

Can you not just change the if statement to do something like this.

if (( Table3.Row1.currentgoal1.rawValue != null) && ( Table3.Row1.currentgoal1.rawValue != "NA"))

{

     goalcount++;

}

this should mean that the goalcount only gets updated if the currentgoal1 is a value that is not "NA"

Regards

Malcolm

Avatar

Level 2

Hi Malcom,

Thank you for the quick response.  I entered the formula in the first goal count only however, it does not seem to work.  Would it need to be added to all in order to work?

HIRE.#subform[6].INDIVIDUALGOALHEADINGSECTION.goalcount::calculate - (JavaScript, client)

var

goalcount = 0

if

((

Table3.Row1.currentgoal1.rawValue

!= null)&&(Table3.Row1.currentgoal1.rawValue!="NA")){

goalcount

= goalcount++;

}

if

(Table3.Row2.currentgoal2.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row3.currentgoal3.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row4.currentgoal4.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row5.currentgoal5.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row6.currentgoal6.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row7.currentgoal7.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row8.currentgoal8.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row9.currentgoal9.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row10.currentgoal10.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row11.currentgoal11.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row12.currentgoal12.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row13.currentgoal13.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row14.currentgoal14.rawValue

!= null){

goalcount

= goalcount + 1;

}

if

(Table3.Row15.currentgoal15.rawValue

!= null){

goalcount

= goalcount + 1;

}

this.rawValue

= goalcount;

Avatar

Level 2

I just realized I failed to explain clearly what is needed.  Sorry about that.  I forgot that when a goal is entered, the formula needs to look at the point field to see if it says "NA".  The goal field is called currentgoal1 and the point field is current1.  So the goal count total needs to look at currentgoal1 then current1 and if "NA" then don't count it.  So currentgoal 1 has texted entered into it, current1 has a value of NA.  Currentgoal2 has text, current2 has a value of 1.  Total goal count is only 1 because NA. 

var

goalcount = 0

if

((

Table3.Row1.currentgoal1.rawValue

!= null)&&(xfa.resolveNode("HIRE.#subform[6].INDIVIDUALGOALHEADINGSECTION.Table3.Row1.current1")!="NA")){

goalcount

++;

}