Skip to main content
Albero Academy

Essential DAX Functions

The DAX vocabulary you use daily — safe division, logical branching with SWITCH, FILTER, RELATED, VALUES and DISTINCTCOUNT.

Chapter 11Power BI15 min readBeginner friendly
  • #Power BI
  • #DAX
  • #Functions

With filter context and iterators understood, you need the everyday functions to build real measures. This chapter is the practical vocabulary — safe division, branching, filtering tables, and pulling values across relationships.

Aggregation & DIVIDE

the basics, done safely
Total Sales = SUM(Sales[Amount])
Orders = COUNTROWS(Sales)
Customers = DISTINCTCOUNT(Sales[CustomerID])
-- ALWAYS use DIVIDE, not / — it returns blank (not an error) on divide-by-zero
Margin % = DIVIDE([Profit], [Total Sales])

IF & SWITCH

IF branches on one condition; SWITCH is the clean way to handle several — much more readable than nested IFs:

branching
Status = IF([Total Sales] > [Target], "Above", "Below")
Band =
SWITCH(
TRUE(),
[Total Sales] >= 1000000, "Platinum",
[Total Sales] >= 500000, "Gold",
[Total Sales] >= 100000, "Silver",
"Bronze" -- the default/else
)

FILTER

FILTER returns a filtered table, usually fed into CALCULATE or an iterator for conditions too complex for a simple CALCULATE filter:

complex conditions
High-Value Sales =
CALCULATE(
[Total Sales],
FILTER(Sales, Sales[Amount] > 10000) -- only big transactions
)

RELATED & VALUES

crossing relationships
-- RELATED pulls a value from the "one" side into the "many" side (in a column/iterator)
Revenue = Sales[Qty] * RELATED(Product[Price])
-- VALUES returns the distinct values currently in filter context
Selected Region = IF(HASONEVALUE(Region[Name]), VALUES(Region[Name]), "All")

Practice

Write measures for order count (COUNTROWS), distinct customers (DISTINCTCOUNT) and a safe margin percentage (DIVIDE). Add a SWITCH(TRUE(), …) band, and a measure that totals only sales above a threshold with FILTER.

Key takeaways

  1. 01Core aggregators: SUM, COUNTROWS, DISTINCTCOUNT; always use DIVIDE for safe division.
  2. 02IF branches on one condition; SWITCH(TRUE(), …) is the clean multi-branch choice.
  3. 03FILTER returns a filtered table for conditions beyond a simple CALCULATE filter.
  4. 04RELATED pulls a value across a relationship (into the many side); VALUES returns distinct in-context values.
  5. 05These functions plus CALCULATE cover the vast majority of real measures.