Search

October 1, 2009

Count

The Count() function can be used to return the number of instances of a given repeated item.

 

Example 1:

Simply return the number of items entered into the repeat. The count() function takes 1 parameter; the name of the parent element.


«ForEach(Child)»
«Child_Name»
«End()»

Number of children: «count(Child)»

 

Example 2:

Use the count() function in a condition to return the correct plural in the document.

«ForEach(Child)»
«Child_Name», (Age «Age»)
«End()»

«When(Count(Child) > 1,Children,Child)»

 

Example 3:

Use the count() function with a different type of condition (predicate) to return a filtered list:

«ForEach(Child)»
«Child_Name», (Age «Age»)
«End()»

Children over the age of 12: «count(Child[Age > 12])»