Syntax

COUNT(some-list)

Arguments

  • some-list (list of any type)

Return Value

Number: The count of items in some-list.

Examples

COUNT(Products[Color]) : The total number of non-blank, possibly duplicate values in the Color column of the Products table. Equivalent to COUNT(SELECT(Products[Color], TRUE, FALSE)). See also SELECT().

COUNT(SELECT(Products[Color], TRUE, TRUE)) : The total number of non-blank, non-duplicate values in the Color column of the Products table.

COUNT(SELECT(Products[Color], IN([Color], {"Red", "Orange"}))) : The total number of non-blank, possibly duplicate values in the Color column of the Products table where the Color column value is either Red or Orange. See also IN().

COUNT(Orders[_RowNumber]) : The total number of rows in the Orders table. Note that this is not equivalent to MAX(Orders[_RowNumber]), which doesn't account for empty (e.g., deleted) rows or a spreadsheet header row. See also MAX().

COUNT([Discounts]) : The count of the items in the Discounts column value, where Discounts is of type List.

COUNT(LIST("Red", "Yellow", "Green")) : 3

COUNT(LIST()) : 0

Count Select Rows

Count orders with special delivery instructions that occur within a reporting period:

COUNT(
  FILTER(
    "Orders",
    AND(
      ISNOTBLANK([Special Instructions]),
      ([Date Done] >= [_THISROW].[Begin Date]),
      ([Date Done] < [_THISROW].[End Date])
    )
  )
)
  • FILTER("Orders",  ...) gets a list of row references (values of the key column)  for select rows in Orders.
  • AND(..., ..., ...) limits the results to only those rows that match all of the conditions.
  • ISNOTBLANK([Special Instructions]) ensures only rows that contain special delivery instructions are counted.
  • ([Date Done] >= [_THISROW].[Begin Date]) limits the count to only rows with a Date Done column value no earlier than the report's Begin Date column value.
  • ([Date Done] < [_THISROW].[End Date]) further limits the rows to those with dates before the report's end date.
  • COUNT(...) counts the number of items selected.

See also: AND(), FILTER(), ISNOTBLANK()

Common Problems

COUNT(1, 2, 3) : The arguments are not in list form. To fix, wrap them in LIST() to construct a list: COUNT(LIST(1, 2, 3)).

See Also

AVERAGE(), MAX(), MIN(), STDEVP(), SUM()

Did this answer your question?