OpenBI Docs Buy

COUNTX

The number of a table's rows where an expression is not blank; for TRUE and FALSE values use COUNTAX.

Group: Aggregation. Compatible with DAX.

Syntax

COUNTX ( <table>, <expression> )
ParameterTypeDescription
tableTableThe rows to go through.
expressionExpression
evaluated for each row
The value worked out for each row: a number, a date or text.

Returns

Whole number. How many rows give a result that is not blank.

Remarks

  • A result of TRUE or FALSE is an error: use COUNTAX for those.
  • Empty text is not blank, so it counts.
  • Over an empty table, or when every result is blank, the answer is BLANK.
  • To count the rows that meet a condition, COUNTROWS ( FILTER ( table, condition ) ) is usually clearer.

Examples

Order lines with liters

EVALUATE
VAR Orders =
    DATATABLE (
        "Product", STRING, "Liters", INTEGER, "Price", DOUBLE,
        { { "Pils", 120, 38 }, { "IPA", 80, 64 }, { "Cider", BLANK (), 52 }, { "Stout", 45, 70 } }
    )
RETURN
    ROW ( "Lines with liters", COUNTX ( Orders, [Liters] ) )
Lines with liters
3

Products that sold in 2026

The measure is blank for a product with no sales in the filter, so it is not counted.

EVALUATE
ROW (
    "Products sold in 2026",
        CALCULATE (
            COUNTX ( Products, [Liters sold] ),
            YEAR ( Sales[Month] ) = 2026
        )
)
Products sold in 2026
4

COUNTAX, COUNT, COUNTROWS, FILTER.

Last updated · OpenBI Studio 0.3.74