The listCount
function iterates through a list and returns the total count of items that meet the specified condition.
setlist: BRANDS
1. Company 1
2. Company 2
3. Company 3
999. Dummy Brand
1. What is your relationship with each of the following suppliers?
type: radio table
1. Never used
2. Used, but not in the past 12 months
3. Used in the past 12 months, but not primary supplier
4. Used in the last 12 months, primary supplier
rowsfrom: BRANDS
P12M. Count of suppliers used in the last 12 months
type: coded number
cvalue: listCount(BRANDS -[999]; anyChecked($Q1R[id],3,4))
termif: listCount(BRANDS -[999]; anyChecked($Q1R[id],4))==0
Tip! Not sure which list function is best suited for your needs? Review all list functions here.
Details
-
In its most basic form,
listCount
accepts two inputs: a list name and a field reference constructed with the '[id]' placeholder. - Options can be filtered in or out of the list with inclusion/exclusion syntax.
-
listCount
can be used in condition logic with tags such astermif
,showif
, andcondition
(e.g.,showif: listCount(T1.rows; anyChecked($Q1R[id],3,4)) > 1
, as well ascvalue
as shown above. - When multiple lists or conditions are used, the list name is prefixed to the
[id]
reference and separated by a colon, (e.g.,[LISTNAME:id]
). Prefixing clarifies list references and is necessary for the software to iterate and sum calculations across different lists. - Though not explicitly tied to tables, table references are imagined to be the most common usage.
Additional examples
Counting all items from multiple lists
In this example, we use two lists in the listCount
function to count the number of items ranked 8 or higher in a pulldown table with multiple columns. The listCount
checks each iteration of row (auto brand) and column (auto type), and if an 8 or higher is found, it will be counted. Each list name is prefixed to the [id]
reference where the list will be iterated through (the rows and columns [id]
placeholders) and separated by a colon.
Comments
0 comments
Please sign in to leave a comment.