You are viewing limited content. For full access, please sign in.

Question

Question

Formula to count rows in a table or to check if a row exists

asked on April 11, 2019

I saw the entry for counting rows in a table with JavaScript. I'm wondering if there's a way to do it in a formula. 

I have a table that can only be 1 or 2 rows deep. Each row contains an account number field. I have another (hidden) field that tells me if any of the account number fields contain a grant account number (account number that starts with 150, 151, 152 or 310). I'm not able to check the 2nd account number, unless the user clicks the "Add" link to display the 2nd row. This is why:  if I include "INDEX(Airfare_Table.Grant_Airfare,2)" somewhere in my formula and there's only 1 row displaying in the Airfare_Table, I get an error. 

Is there a way around this, other than using JavaScript to count the number of rows and put it in another hidden field to reference in my formula?

 

0 0

Answer

SELECTED ANSWER
replied on April 11, 2019

Something like this might work

=IF(COUNTIF(Airfare_Table.Grant_Airfare,"<> ")>1,INDEX(Airfare_Table.Grant_Airfare,2),"DEFAULT")

This counts each row of the grant_airfare column as long as it isn't blank, and if the value is greater than one it uses the index, otherwise it can set a default or blank value.

2 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.