How to Count Values in a Column in Power BI

Cody Schneider7 min read

Knowing how to count values in a Power BI column is one of the most fundamental skills you can learn, serving as the building block for nearly every report you'll create. Whether you need to find the total number of sales, the unique count of customers, or how many products meet a specific criterion, it all starts with counting. This guide will walk you through the essential DAX functions and methods to count values, from basic totals to more complex conditional counts.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Understanding the Core DAX Counting Functions

Power BI's formula language, Data Analysis Expressions (DAX), offers several functions for counting. Choosing the right one depends entirely on what you need to count. Let's look at the three most common ones: COUNT, COUNTA, and DISTINCTCOUNT.

1. COUNT: For Numbers and Dates

The COUNT function is the most specific of the bunch. It only counts cells in a column that contain numbers, dates, or strings that can be interpreted as numbers. If the column contains text or blank values, COUNT will ignore them.

  • Use it when: You want to count rows based on a purely numerical or date-based column, like [OrderID], [TransactionValue], or [ShipDate].
  • Keep in mind: If your OrderID column was 'AB-101', 'AB-102', etc., COUNT would return zero because those are text strings, not numbers.

2. COUNTA: For All Non-Blank Values

The COUNTA function (think "Count All") is more versatile. It counts every row in a column that is not empty (blank). This makes it perfect for counting text-based values like customer names, product categories, or status labels.

  • Use it when: You need to count the total number of entries in a column, regardless of data type (text, numbers, dates). For example, counting how many sales transactions have an assigned CustomerName.
  • Keep in mind: Since it counts everything that isn't blank, any row with a value - even "N/A" or "0" - will be included in the count.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

3. DISTINCTCOUNT: For Unique Values

This is arguably one of the most valuable counting functions. DISTINCTCOUNT counts only the unique, or distinct, values in a column. If a value appears multiple times, it’s only counted once. This is essential for finding out things like how many unique customers you have, not just how many sales you've made.

  • Use it when: You need to answer "how many different..." types of something you have. For instance, "How many unique customers made a purchase?" or "How many distinct products were sold this month?"
  • Example: If your [Customer] column looks like ['Bob', 'Jane', 'Bob', 'Alice', 'Jane'], COUNTA would give you 5, but DISTINCTCOUNT would correctly tell you there are only 3 unique customers: Bob, Jane, and Alice.

How to Create a Count Measure in Power BI

Abstract definitions are one thing, but let’s put these functions into practice. In Power BI, you'll perform these calculations by creating a "Measure." A measure is a reusable formula that you can add to any visual in your report. Here's how you do it.

Let's assume you have a 'Sales' table with columns like [OrderID], [CustomerName], and [Product].

Step 1: Open the New Measure Window

In the main Power BI Desktop view, navigate to the Data pane on the right-hand side. Find your table (e.g., 'Sales'), right-click on it, and select New measure. This will open the formula bar at the top of your screen.

Step 2: Write Your DAX Formula

In the formula bar, you'll write your DAX calculation. They follow a simple syntax: Measure Name = FUNCTION(TableName[ColumnName]).

Here are examples for each of our core functions:

To count total numerical transaction IDs:

Total Transactions = COUNT('Sales'[OrderID])

To count total rows with a customer name (non-blanks):

Count of Sales with Customer Info = COUNTA('Sales'[CustomerName])

To count the number of unique customers:

Unique Customers = DISTINCTCOUNT('Sales'[CustomerName])

After typing in your formula, hit Enter or click the checkmark icon to save the measure.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Step 3: Use Your New Measure in a Visual

Once created, your new measure will appear in the Data pane underneath your table, indicated by a small calculator icon. To see the result, you can drag and drop it onto a visual.

  • Card Visual: For a simple, big-number KPI, drag your Unique Customers measure onto a Card visual. It will display a single number – your total unique customers.
  • Table Visual: To see your count broken down by a category, create a Table visual. Drag a column like [Product Category] into it, and then drag your Total Transactions measure. You'll see the total transaction count for each category automatically.

Conditional Counting: How to Count with Filters

What if you need to be more specific? For example, "How many sales were from the USA?" or "How many orders were over $500?" This is called conditional counting, and it’s where DAX gets really powerful. For this, we'll combine the COUNTROWS and FILTER functions.

  • COUNTROWS(TableName): Does exactly what it says – counts the rows in a table.
  • FILTER(TableName, [Condition]): Creates a temporary, virtual table containing only the rows from TableName that meet your [Condition].

By using COUNTROWS on the table created by FILTER, you can count exactly what you need.

Example 1: Counting Sales from a Specific Country

Let’s count how many sales transactions in our 'Sales' table came from the 'USA'.

Create a new measure with this formula:

USA Sales Count =
CALCULATE(
    COUNTROWS('Sales'),
    'Sales'[Country] = "USA"
)

Note: While you can use COUNTROWS(FILTER('Sales', 'Sales'[Country] = "USA")), the CALCULATE function is often the standard and more efficient way to apply filters in DAX. It modifies the filter context for the calculation inside it.

Example 2: Counting High-Value Orders

Now, let’s find the number of orders with a value greater than $500.

High Value Orders =
CALCULATE(
    COUNTROWS('Sales'),
    'Sales'[OrderValue] > 500
)

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Example 3: Counting with Multiple Conditions

You can layer filters too. Let's find the number of high-value orders ($500+) from the USA, originating from a specific marketing campaign, Summer Sale.

USA High Value Summer Sale Orders =
CALCULATE(
    COUNTROWS('Sales'),
    'Sales'[Country] = "USA",
    'Sales'[OrderValue] > 500,
    'Sales'[Campaign] = "Summer Sale"
)

This measure now gives you a highly specific count that you can use as a KPI in your report.

Putting It All Together: Best Practices and Tips

  • Always Create Measures: It might be tempting to use Power BI's default summarizations by dragging a column into a visual and choosing "Count". While this works for quick checks, creating dedicated DAX measures is far more robust, reusable, and powerful for building reliable reports.
  • Name Measures Clearly: Name your measures something descriptive. Total Orders Not Delivered is much better than Count2. This makes your data model easier for you and your colleagues to understand.
  • Understand Filter Context: Remember that your measures are calculated within a "filter context." When you put Unique Customers in a table next to a [Month] column, DAX automatically calculates the unique customers for that specific month. You don't need a separate formula for every month.
  • Don't Be Afraid of Blanks: DISTINCTCOUNT counts blanks as a distinct value. If your customer data has empty rows, they'll show up as a (Blank) category in visuals. This is often a helpful signal that your underlying data needs cleaning.

Final Thoughts

Mastering how to count values is a significant first step toward becoming proficient in Power BI. By understanding the difference between COUNT, COUNTA, and DISTINCTCOUNT, and then learning to apply conditions with CALCULATE or COUNTROWS and FILTER, you can extract vital performance indicators from your raw data and start telling a meaningful story.

Building these foundational calculations is critical, but sometimes you just need an answer without writing DAX and setting up visuals. This is where we built Graphed to simplify the entire process. Rather than remembering which DAX function to use, you can connect your data sources (like Shopify or Google Analytics) and just ask in plain language, "what was the number of unique customers who bought product 'X' last month in the USA?" Graphed creates the chart for you in seconds, saving you from the manual work of building reports from scratch.

Related Articles