Skip to main content
Henry.Ong
Inspiring
October 28, 2022
Answered

How to count the number of fields in a column with date entries?

  • October 28, 2022
  • 1 reply
  • 1854 views

Good day!

 

I have a fillable PDF containing a table with a date column.

 

Assuming the field names of the dates with the format (mm/dd/yyyy) in the column are:

 

F01001c

F01002c

F01003c

F01004c

F01005c

to

F010nnc where 'nn' is the row number of the last date.

 

The field name of the total count field is FTOTAL which is located in the last row of the column.

 

I wish to count the number of date fields with entries. In other words, if F01002c, F01004c, F01005c, F01014c, and F01021c are with dates, the count should be 5.

 

Any help is highly appreciated. Thank you.

This topic has been closed for replies.
Correct answer Nesa Nurani

You can use this as custom calculation script of "FTOTAL" field:

var total = 0;
for( var i=1; i<=nn; i++){
if(this.getField("F0100"+i+"c").valueAsString != "")total++;}
event.value = total;

Since you didn't mention how many fields there are in a column,  replace nn with number of those fields.

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
October 28, 2022

You can use this as custom calculation script of "FTOTAL" field:

var total = 0;
for( var i=1; i<=nn; i++){
if(this.getField("F0100"+i+"c").valueAsString != "")total++;}
event.value = total;

Since you didn't mention how many fields there are in a column,  replace nn with number of those fields.

Henry.Ong
Henry.OngAuthor
Inspiring
October 28, 2022

Hi Nesa,

 

Thanks. I think I can now manage to replace the 'nn' with the actual number of rows.

 

This is a big help.