pbPassingBI
/

Which function returns the number of items in a group?

beginner
Answer

`COUNT()` returns the number of items in a group, ignoring nulls.

The related ones worth knowing together:

  • `COUNT([field])` — non-null values. - `COUNTD([field])` — distinct non-null values. - `SUM([Number of Records])`, or `COUNT(*)` behaviour, for the row count regardless of nulls.

The distinction matters. On a nullable column, `COUNT` and the row count disagree, and which one is correct depends on the question being asked.

`COUNTD` is worth flagging as the expensive one — distinct counts are costly on large data and on a live connection, and are a common cause of a slow view.

Related questions