Hello! Welcome to the next lesson in our "DAX Fundamentals" module.
In our previous lesson, you learned how to create calculated columns to add new, static information to your tables on a row-by-row basis. We saw how this is perfect for creating new categories for filtering or performing simple arithmetic within a single row.
Today, we shift our focus to measures. While calculated columns store values in your model, measures perform calculations on the fly, summarizing vast amounts of data to answer key business questions. Your goal for this lesson is to write basic DAX measures using SUM, AVERAGE, COUNT, and DISTINCTCOUNT. These functions are the foundational building blocks for almost all analysis you will perform.
Why Write Measures? The Power of Explicit Calculation
Before we write any code, it's crucial to understand why we write measures. Power BI allows you to drag a numeric field (like 'Sales Amount') into a visual, and it will automatically create a "Sum of Sales Amount." This is called an implicit measure.
However, as a data analyst, you should always create explicit measures by writing the DAX formula yourself. Why?
- Reusability: An explicit measure can be used in many different visuals and even in other measures.
- Clarity: A measure named
Total Revenueis much clearer thanSum of Gross Sales. - Control: You have full control over the calculation, formatting, and how it behaves.
- Scalability: It's the only way to build more complex business logic later on.
To drive this point home, let's watch a short segment that explains the difference and the importance of committing to explicit measures.
Learn 80% of DAX in an Hour (with FREE sample file)
The video 'Learn 80% of DAX in an Hour' from the Chandoo YouTube channel provides an excellent explanation of why explicit measures are a best practice in Power BI.
Watch from the beginning of the DAX introduction at 03:03 to 04:55, and then skip to the section comparing implicit and explicit measures from 10:50 to 13:40. Pay close attention to the argument for why you should always write your own measures.
The Anatomy of a Measure
A measure has a simple structure:Measure Name = DAX Function(<arguments>)
Let's build our first and most common measure: Total Revenue.
Aggregation with SUM
The SUM function adds all the numbers in a column. It's the cornerstone of many financial KPIs.
Dive Into DAX: Data Aggregation Made Easy
The article 'Dive Into DAX: Data Aggregation Made Easy' gives a concise overview of the SUM function. We'll use this as a quick reference for its syntax.
Read the section 'SUMming It Up: The Power of Basic Aggregations', focusing on the syntax and the first example for TotalSales.
Now, let's see this in action. The same video from Chandoo demonstrates creating a Total Amount measure step-by-step.
Learn 80% of DAX in an Hour (with FREE sample file)
This segment will walk you through creating your very first explicit measure using the SUM function.
Watch from 05:05 to 10:50. Follow along as the instructor creates the 'Total Amount' measure. Notice how you can right-click the table, select 'New Measure', and how the formula bar appears. Also, pay attention to the formatting options available in the 'Measure tools' ribbon.
Counting What Matters: COUNT and DISTINCTCOUNT
Summarizing values is essential, but so is counting things. DAX provides several functions for this, but we'll focus on two key scenarios: counting the number of transactions and counting the number of unique items.
1. Counting All Transactions with COUNTROWS
When you want to know "how many," your first instinct might be the COUNT function. COUNT tallies the non-blank values in a specific column. However, a more direct and often more efficient way to count the number of transactions (i.e., rows in your sales table) is COUNTROWS.
Let's see how to create a measure to count our total shipments or transactions.
Learn 80% of DAX in an Hour (with FREE sample file)
We'll return to the Chandoo video to see a practical example of creating a count measure.
Watch from 15:12 to 16:11. The instructor creates a 'Shipment Count' measure using COUNTROWS(Shipments). This is a best practice for counting the total number of records in a table.
2. Counting Unique Items with DISTINCTCOUNT
What if your business question is "How many unique customers made a purchase?" or "How many different products did we sell?" Simply counting rows won't answer this. For this, you need DISTINCTCOUNT.

Power BI DAX Tutorial for Beginners - Pickl.AI
This article from Pickl.AI clearly explains the purpose of several key aggregate functions, including DISTINCTCOUNT.
Read the section 'Example 2: Using Aggregate Functions in DAX'. Focus on the explanations and formulas for SUM, AVERAGE, COUNT, and especially DISTINCTCOUNT.
Finding the Middle Ground: AVERAGE
The AVERAGE function calculates the arithmetic mean of all numbers in a column. This is useful for KPIs like "Average Sale Value" or "Average Order Quantity."

The syntax is straightforward: AVERAGE(<columnName>). As you saw in the Pickl.AI article, it works just like SUM, but calculates the mean instead of the total.
Your Turn: Practice Creating Basic Measures
It's time to apply these concepts. Open your Power BI file with the sales data. Navigate to the Data or Report view, right-click on your Sales table in the Data pane, and select New measure for each of the following tasks.
-
Total Revenue
- Name:
Total Revenue - Goal: Calculate the sum of all sales.
- DAX Formula:
Total Revenue = SUM(Sales[Gross Sales]) - Note: We are using the
Gross Salescalculated column you created in the last lesson.
- Name:
-
Transaction Count
- Name:
Transaction Count - Goal: Count the total number of sales transactions.
- DAX Formula:
Transaction Count = COUNTROWS(Sales)
- Name:
-
Unique Customers
- Name:
Unique Customers - Goal: Count the number of distinct customers who have made a purchase.
- DAX Formula:
Unique Customers = DISTINCTCOUNT(Sales[CustomerKey])
- Name:
-
Average Revenue per Transaction
- Name:
Average Revenue - Goal: Calculate the average revenue for each transaction.
- DAX Formula:
Average Revenue = AVERAGE(Sales[Gross Sales])
- Name:
After creating these measures, drag them into a Card visual on your report canvas to see the results.
Conclusion
Congratulations! You have just created your first set of explicit measures, which are the fundamental KPIs for any sales analysis. You now have the tools to summarize your data and answer core business questions.
Key Takeaways:
- Explicit measures are a best practice for creating reusable, scalable, and clear calculations.
SUMaggregates the total value of a numeric column.COUNTROWSis the standard way to count the number of rows (e.g., transactions) in a table.DISTINCTCOUNTis used to count the number of unique items in a column (e.g., customers, products).AVERAGEcalculates the arithmetic mean of a column.
Preview of the Next Lesson:
In our practice, we created Total Revenue and Transaction Count. A very common next step would be to calculate the Average Revenue per Transaction by dividing one by the other. While AVERAGE(Sales[Gross Sales]) works, sometimes you need to divide two existing measures. In the next lesson, we will learn how to do this safely using the DIVIDE function, which helps prevent errors when the denominator is zero.