Count months with sales: COUNTX vs COUNTROWS

Count only the months in which a product actually sold, and see why COUNTROWS counts the empty months too.

You will learn to

  • Count non-blank results with COUNTX
  • Explain the difference between COUNTX and COUNTROWS
  • Measure how consistently something sells

How it works

`COUNTROWS(table)` counts rows, no questions asked. `COUNTX(table, expression)` evaluates the expression for each row and counts only the results that are **not blank**.

That difference matters with dimension tables. Filters flow from Date to Sales, not from Product to Date, so in a Road-150 row `VALUES('Date'[Month Year])` still lists all 24 months, including months when nobody bought a Road-150.

Hand COUNTX a measure as its expression and the blank months drop out: context transition filters the measure to each month, and empty months return blank. What is left is the number of months with at least one sale.

Practice it hands-on with a real data model and a live report that updates as you type.

Customers Buying = COUNTX(Customer, [Total Sales])