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

Discussion

Discussion

Feature Request: Table/Collection "Prop Count" as an accessible variable

posted on October 5, 2018 Show version history

Hello,

I was reading a post yesterday about how to count the number of rows/items in a Collection/Table and it got me thinking.

I know Forms uses a hidden input field with the "propCount" class to track this information and I think it may be useful to expose that as a variable in Forms.

If each table/collection had a PropCount attribute/field it could be accessed for things like functions and form routing without relying exclusively on JavaScript.

As an example,

I could use a gateway decision based on the value of Collection.PropCount or use Table.PropCount in Function calculations.

Just food for thought. I figured it might be a fairly easy thing to add since Forms is already tracking this value.

4 0
replied on October 8, 2018 Show version history

One way to do this without JS is to add a read-only number field to the table/collection with a default value of 1. Outside of the table/collection, you can use the formula SUM(Collection.Number) to sum up all of the 1s to count the number of rows. You could use a field rule to hide the field as well. 

You could also try and use a formula without adding an additional hidden field. Something like COUNTIF(Collection.Single_Line,"<>%^&%") will count the number of rows in a specific column of a collection/table that match (or don't match) a specific string. If you just use "<>", it will ignore blanks and only count the rows with values in that column. My example only ignores that random string (which presumably wouldn't appear in your table) so it should count all table rows, regardless of value. 

3 0
replied on October 8, 2018 Show version history

Thanks for the suggestion. Adding the ROW() function to the field would probably work as well if your reference the max value, however, both would still require an additional column and a field outside of the table to make the value accessible in gateway conditions. Although this isn’t a bad approach, in some situations I have tables with so many rows and columns that browser load times can be a problem and adding even one more column can cause issues, so a dedicated variable would be much more efficient.

0 0
replied on October 8, 2018

The second approach just uses a formula on a single field outside the table. You can run countif on an existing column. 

1 0
replied on December 6, 2019

Worked like a charm, thanks!

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

Sign in to reply to this post.