Tag: DAX

COUNT vs. COUNTA in Power BI DAX: When and How to Use Each

When building measures in Power BI using DAX, two commonly used aggregation functions are COUNT and COUNTA. While they sound similar, they serve different purposes and choosing the right one can prevent inaccurate results in your reports.

COUNT: Counting Numeric Values Only

The COUNT function counts the number of non-blank numeric values in a column.

DAX syntax:
COUNT ( Table[Column] )

Key characteristics of COUNT”:

  • Works only on numeric columns
  • Ignores blanks
  • Ignores text values entirely

When to use COUNT:

  • You want to count numeric entries such as:
    • Number of transactions
    • Number of invoices
    • Number of scores, quantities, or measurements
  • The column is guaranteed to contain numeric data

Example:
If Sales[OrderAmount] contains numbers and blanks, COUNT(Sales[OrderAmount]) returns the number of rows with a valid numeric amount.

COUNTA: Counting Any Non-Blank Values

The COUNTA function counts the number of non-blank values of any data type, including text, numbers, dates, and Boolean values.

DAX syntax:
COUNTA ( Table[Column] )

Key characteristics of “COUNTA”:

  • Works on any column type
  • Counts text, numbers, dates, and TRUE/FALSE
  • Ignores blanks only

When to use COUNTA:

  • You want to count:
    • Rows where a column has any value
    • Text-based identifiers (e.g., Order IDs, Customer Names)
    • Dates or status fields
  • You are effectively counting populated rows

Example:
If Customers[CustomerName] is a text column, COUNTA(Customers[CustomerName]) returns the number of customers with a non-blank name.

COUNT vs. COUNTA: Quick Comparison

FunctionCountsIgnoresTypical Use Case
COUNTNumeric values onlyBlanks and textCounting numeric facts
COUNTAAny non-blank valueBlanks onlyCounting populated rows

Common Pitfall to Avoid

Using COUNTA on a numeric column can produce misleading results if the column contains zeros or unexpected values. Remember:

  • Zero (0) is counted by both COUNT and COUNTA
  • Blank is counted by neither

If you are specifically interested in numeric measurements, COUNT is usually the safer and clearer choice.

In Summary

  • Use COUNT when the column represents numeric data and you want to count valid numbers.
  • Use COUNTA when you want to count rows where something exists, regardless of data type.

Understanding this distinction ensures your DAX measures remain accurate, meaningful, and easy to interpret.

Thanks for reading!

Creating a DATE value in Power BI DAX, Power Query M, and Excel

You may at times need to create a date value in Power BI either using DAX or M, or in Excel. This is a quick post that describes how to create a date value in Power BI DAX, Power Query M language, and in Excel. Working with dates is an every-day thing for anyone that works with data.

In Power BI DAX, the syntax is:

DATE(<year>, <month>, <day>) //the parameters must be valid numbers

DATE(2025, 8, 23) //returns August 23, 2025

In Power Query M, the syntax is:

#date(<year>, <month>, <day>) //the parameters must be valid numbers

#date(2022, 3, 6) //returns March 6, 2022

In Excel, the syntax is:

DATE(<year>, <month>, <day>) //the parameters must be valid numbers

DATE(1989, 12, 3) //produces 12/3/1989 (officially returns a number that represents the date in Excel date-time code)

Thanks for reading. Hope you found this useful.