Menu

Creating and Validating Your First DAX Measures

Creating and Validating Your First DAX Measures

Let's create a small collection of measures for a sales report.

Assume your Power BI model contains a Sales table with SalesAmount, Quantity, and OrderID columns.

Step 1: Create a Total Sales Measure

Select the Sales table, choose New measure, and enter:

Total Sales = SUM(Sales[SalesAmount])

This measure calculates the sum of SalesAmount under the current filter context.

Step 2: Calculate Total Quantity

Create another measure:

Total Quantity = SUM(Sales[Quantity])

This calculates the total quantity sold for the current context.

Step 3: Count Unique Orders

Create a measure that counts distinct order identifiers:

Unique Orders = DISTINCTCOUNT(Sales[OrderID])

This is useful when multiple rows can belong to the same order.

Step 4: Calculate Average Order Value

Average order value can be calculated by dividing total sales by the number of unique orders.

Average Order Value =

DIVIDE(

[Total Sales],

[Unique Orders],

0

)

This calculation returns total sales divided by distinct orders, with zero used when the denominator is zero or blank.

It assumes that the SalesAmount column represents the revenue that should be included in the calculation and that OrderID identifies orders correctly.

Step 5: Display the Measures

Add Card visuals to a report page and place one measure in each card:

  • Total Sales.
  • Total Quantity.
  • Unique Orders.
  • Average Order Value.

Apply appropriate number formats, such as currency for Total Sales and Average Order Value.

Step 6: Validate the Results

Add a product category slicer and select different categories.

Check whether the measures update as expected. Compare their results with the source data or a trusted calculation.

If a result is unexpected, check the following:

  • Whether the source columns contain valid data.
  • Whether the aggregation is correct.
  • Whether relationships are configured properly.
  • Whether slicers and filters apply as intended.
  • Whether the formula matches the business definition of the metric.

Validating DAX measures helps prevent incorrect figures from appearing in business reports.

By mastering basic syntax, calculated columns, measures, common functions, and evaluation context, you establish the foundation needed to build more advanced calculations in Power BI.


Power BI Tutorial

VA

Vishalini A



Learn via Video Course

Microsoft Power BI Logo

Microsoft Power BI

3 hrs



Get in Touch For Details