# How does work the Count() function?

**URL:** <https://the.fmsoup.org/t/how-does-work-the-count-function/3481>\
**Category:** Questions\
**Tags:** calculations\
**Created:** [March 24, 2023, 6:42pm UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481 "2023-03-24T18:42:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![planteg](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/planteg/32/627_2.png) [@planteg](https://the.fmsoup.org/u/planteg)\
**Post date:** [March 24, 2023, 6:42pm UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481/1 "2023-03-24T18:42:45Z")

</div>

Hi,

the question says it all. The documentation reads **Returns the number of valid, non-blank values in a field**. What is a _value_ in there ?

It's Friday afternoon, and my mind just can't understand.

Many thanks

---

<div class="post-metadata">

**Author:** ![bdbd](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bdbd/32/620_2.png) [@bdbd](https://the.fmsoup.org/u/bdbd)\
**Post date:** [March 24, 2023, 6:55pm UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481/2 "2023-03-24T18:55:05Z")

</div>

Non-blank means isempty (field) would return false. Valid applies to fields that expect a value type (date, time, timestamp). A ? in these fields indicates an invalid value.

---

<div class="post-metadata">

**Author:** ![bdbd](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bdbd/32/620_2.png) [@bdbd](https://the.fmsoup.org/u/bdbd)\
**Post date:** [March 24, 2023, 6:56pm UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481/3 "2023-03-24T18:56:03Z")

</div>

And I forgot… value is anything, including nothing, in a field.

---

<div class="post-metadata">

**Author:** ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)\
**Post date:** [March 24, 2023, 6:56pm UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481/4 "2023-03-24T18:56:26Z")

</div>

Just as it says. If a field is empty, it doesn't count 😄

think of survey responses. Count how many people provided an answer to question 3.

---

<div class="post-metadata">

**Author:** ![bdbd](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bdbd/32/620_2.png) [@bdbd](https://the.fmsoup.org/u/bdbd)\
**Post date:** [March 24, 2023, 8:20pm UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481/5 "2023-03-24T20:20:54Z")

</div>

I am copying a response to a private message to clarify my last post in this conversation.

A value, in the context of a field, is the field's content. If a field contains nothing, then nothing is its value. An empty value is still a value.

From a statistical perspective, empty values are omitted from statistical sets because they are considered invalid, missing or non-existant values. Empty values require a proxy to be considered in statistics. Proxy, here, could be a calculated field that equates empty to a non-empty value, such as true or false. IsEmpty (value) is one such calculation.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![planteg](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/planteg/32/627_2.png) [@planteg](https://the.fmsoup.org/u/planteg)\
**Post date:** [March 24, 2023, 9:21pm UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481/6 "2023-03-24T21:21:30Z")

</div>

To sum up,

Count() works with the record set for the TO the Layout is based on - in fact the Found Set if a Find was executed. It goes through this set and count the fields that are not empty.

Whew, now I understand what the original developer was doing. He writes something in this field under a certain condition or wipe.

Count() in the hep file could benefit from a revision IMHO.

---

<div class="post-metadata">

**Author:** ![bdbd](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bdbd/32/620_2.png) [@bdbd](https://the.fmsoup.org/u/bdbd)\
**Post date:** [March 24, 2023, 11:10pm UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481/7 "2023-03-24T23:10:36Z")

</div>

Count doesn't work on found sets. It works on a related set or a series of values. If you give it a field of the current context, it will only count the value of the current record.

There is a summary field type equivalent to Count. Summary fields source their values based on the found set.

---

<div class="post-metadata">

**Author:** ![planteg](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/planteg/32/627_2.png) [@planteg](https://the.fmsoup.org/u/planteg)\
**Post date:** [March 25, 2023, 3:35am UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481/8 "2023-03-25T03:35:26Z")

</div>

Thanks for the added explanation.

---

<div class="post-metadata">

**Author:** ![Kirk](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/kirk/32/2197_2.png) [@Kirk](https://the.fmsoup.org/u/Kirk)\
**Post date:** [December 30, 2023, 1:09am UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481/9 "2023-12-30T01:09:27Z")

</div>

The “count” set of functions is a bit more nuanced than the provided explanations.

COUNT works across a relationship for records. The relationship provide the impetus for the found set of child records (think of relationships in FileMaker as being equivalent to queries)

But the equivalent exists in a single table; the summary calc COUNT auto calculates to the found set in that table.

In either case, the function has to traverse the set of records in order to return a value.

A very common use case for count is the number of records in a related table BUT it can be accomplished far faster by setting an UNSTORED calculation field in each table that does a Get(FoundCount). Referencing this field across a relationship gets a record count of the related records without the overhead of a parent count calculation.

Another TRICK in the stable of Count approaches is a combination of the list command (across a relationship) and a patternCount. I use this a lot for quick dashboards displayed in segments of a button bar.

PatternCount ( list ( relatedPRIORITYfield ) ; “high” )

Returns the number of priority items in the child table that are high priority. Repeat for each

A general tip; look at the list of summary calculation options. Each works within the scope of a single table AND each has an equivalent calculation command to work across relationships. Both have situational value.

---

<div class="post-metadata">

**Author:** ![bdbd](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/bdbd/32/620_2.png) [@bdbd](https://the.fmsoup.org/u/bdbd)\
**Post date:** [December 30, 2023, 2:40pm UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481/10 "2023-12-30T14:40:12Z")

</div>

> [@Kirk](#):
>
> PatternCount ( list ( relatedPRIORITYfield ) ; “high” )

That can fail if a list contains, say, "high school" and "highlight". I suggest the following instead:

```auto
ValueCount (FilterValues (List (relatedField); "high))

```

---

<div class="post-metadata">

**Author:** ![Kirk](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/kirk/32/2197_2.png) [@Kirk](https://the.fmsoup.org/u/Kirk)\
**Post date:** [December 30, 2023, 5:07pm UTC](https://the.fmsoup.org/t/how-does-work-the-count-function/3481/11 "2023-12-30T17:07:36Z")

</div>

Good approach on a list of data that is highly variable - you'd have to add those filter value items to the command, or use ValueListItems () to get there. That chain of 4 nested commands would be more readable in a sequence of LET statements, accomplishing the same thing.

For things like Priority, a value list limits the input.  
A popup field is best for short lists, especially on Windows where type-ahead in popup lists does not work, as it does not allow alternative input.  
A drop down field works best if on windows for longer lists, but adding the field validation of always matching value list content is "nagware" - not a fan, but forced to comply on Windows.
