0
0
Power-biHow-ToBeginner ยท 3 min read

How to Use COUNT in DAX in Power BI: Simple Guide

In Power BI, use the COUNT function in DAX to count the number of rows that contain numbers in a specific column. The syntax is COUNT(columnName), where columnName is the column you want to count. This function ignores blank or non-numeric values.
๐Ÿ“

Syntax

The COUNT function counts the number of rows in a column that contain numeric values.

  • columnName: The column you want to count numbers in.

It only counts rows with numbers and ignores blanks or text.

DAX
COUNT(<columnName>)
๐Ÿ’ป

Example

This example counts how many rows in the Sales[Quantity] column have numbers.

DAX
TotalCount = COUNT(Sales[Quantity])
Output
If Sales[Quantity] has values: 5, 3, blank, 7, blank, 2, the result is 4
โš ๏ธ

Common Pitfalls

Counting non-numeric values: COUNT ignores text and blanks, so it won't count rows with text.

Wrong function for counting all rows: Use COUNTROWS to count all rows regardless of content.

Counting text values: Use COUNTA if you want to count all non-blank rows including text.

DAX
WrongCount = COUNT(Sales[CustomerName])  // Returns 0 if CustomerName is text
CorrectCount = COUNTA(Sales[CustomerName])  // Counts all non-blank text rows
๐Ÿ“Š

Quick Reference

FunctionPurposeCounts
COUNT(column)Counts numeric values onlyNumbers only, ignores blanks and text
COUNTA(column)Counts all non-blank valuesNumbers, text, dates, etc.
COUNTROWS(table)Counts all rows in a tableAll rows regardless of content
โœ…

Key Takeaways

Use COUNT(column) to count only numeric values in a column.
COUNT ignores blanks and text values; it counts numbers only.
Use COUNTA to count all non-blank values including text.
Use COUNTROWS to count all rows in a table regardless of content.
Choose the right counting function based on your data type and goal.