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
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-zeroMargin % = 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:
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:
High-Value Sales =CALCULATE([Total Sales],FILTER(Sales, Sales[Amount] > 10000) -- only big transactions)
RELATED & VALUES
-- 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 contextSelected 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
- 01Core aggregators: SUM, COUNTROWS, DISTINCTCOUNT; always use DIVIDE for safe division.
- 02IF branches on one condition; SWITCH(TRUE(), …) is the clean multi-branch choice.
- 03FILTER returns a filtered table for conditions beyond a simple CALCULATE filter.
- 04RELATED pulls a value across a relationship (into the many side); VALUES returns distinct in-context values.
- 05These functions plus CALCULATE cover the vast majority of real measures.
