
This post is a part of the DP-600: Implementing Analytics Solutions Using Microsoft Fabric Exam Prep Hub; and this topic falls under these sections:
Prepare data
--> Query and analyze data
--> Select, Filter, and Aggregate Data Using DAX
Data Analysis Expressions (DAX) is a formula language used to create dynamic calculations in Power BI semantic models. Unlike SQL or KQL, DAX works within the analytical model and is designed for filter context–aware calculations, interactive reporting, and business logic. For DP-600, you should understand how to use DAX to select, filter, and aggregate data within a semantic model for analytics and reporting.
What Is DAX?
DAX is similar to Excel formulas but optimized for relational, in-memory analytics. It is used in:
- Measures (dynamic calculations)
- Calculated columns (row-level derived values)
- Calculated tables (additional, reusable query results)
In a semantic model, DAX queries run in response to visuals and can produce results based on current filters and slicers.
Selecting Data in DAX
DAX itself doesn’t use a traditional SELECT statement like SQL. Instead:
- Data is selected implicitly by filter context
- DAX measures operate over table columns referenced in expressions
Example of a simple DAX measure selecting and displaying sales:
Total Sales = SUM(Sales[SalesAmount])
Here:
Sales[SalesAmount]references the column in the Sales table- The measure returns the sum of all values in that column
Filtering Data in DAX
Filtering in DAX is context-driven and can be applied in multiple ways:
1. Implicit Filters
Visual-level filters and slicers automatically apply filters to DAX measures.
Example:
A card visual showing Total Sales will reflect only the filtered subset by product or date.
2. FILTER Function
Used within measures or calculated tables to narrow down rows:
HighValueSales = CALCULATE(
SUM(Sales[SalesAmount]),
FILTER(Sales, Sales[SalesAmount] > 1000)
)
Here:
FILTERreturns a table with rows meeting the conditionCALCULATEmodifies the filter context
3. CALCULATE as Filter Modifier
CALCULATE changes the context under which a measure evaluates:
SalesLastYear = CALCULATE(
[Total Sales],
SAMEPERIODLASTYEAR(Date[Date])
)
This measure selects data for the previous year based on current filters.
Aggregating Data in DAX
Aggregation in DAX is done using built-in functions and is influenced by filter context.
Common Aggregation Functions
SUM()— totals a numeric columnAVERAGE()— computes the meanCOUNT()/COUNTA()— row countsMAX()/MIN()— extreme valuesSUMX()— row-by-row iteration and sum
Example of row-by-row aggregation:
Total Profit = SUMX(
Sales,
Sales[SalesAmount] - Sales[Cost]
)
This computes the difference per row and then sums it.
Filter Context and Row Context
Understanding how DAX handles filter context and row context is essential:
- Filter context: Set by the report (slicers, column filters) or modified by
CALCULATE - Row context: Used in calculated columns and iteration functions (
SUMX,FILTER)
DAX measures always respect the current filter context unless explicitly modified.
Grouping and Summarization
While DAX doesn’t use GROUP BY in the same way SQL does, measures inherently aggregate over groups determined by filter context or visual grouping.
Example:
In a table visual grouped by Product Category, the measure Total Sales returns aggregated values per category automatically.
Time Intelligence Functions
DAX includes built-in functions for time-based aggregation:
TOTALYTD(),TOTALQTD(),TOTALMTD()— year-to-date, quarter-to-date, month-to-dateSAMEPERIODLASTYEAR()— compare values year-over-yearDATESINPERIOD()— custom period
Example:
SalesYTD = TOTALYTD(
[Total Sales],
Date[Date]
)
Best Practices
- Use measures, not calculated columns, for dynamic, filter-sensitive aggregations.
- Let visuals control filter context via slicers, rows, and columns.
- Avoid unnecessary row-by-row calculations when simple aggregation functions suffice.
- Explicitly use
CALCULATEto modify filter context for advanced scenarios.
When to Use DAX vs SQL/KQL
| Scenario | Best Tool |
|---|---|
| Static relational querying | SQL |
| Streaming/event analytics | KQL |
| Report-level dynamic calculations | DAX |
| Interactive dashboards with slicers | DAX |
Example Use Cases
1. Total Sales Measure
Total Sales = SUM(Sales[SalesAmount])
2. Filtered Sales for Big Orders
Big Orders Sales = CALCULATE(
[Total Sales],
Sales[SalesAmount] > 1000
)
3. Year-over-Year Sales
Sales YOY = CALCULATE(
[Total Sales],
SAMEPERIODLASTYEAR(Date[Date])
)
Key Takeaways for the Exam
- DAX operates based on filter context and evaluates measures dynamically.
- There is no explicit
SELECTstatement — rather, measures compute values based on current context. - Use
CALCULATEto change filter context. - Aggregation functions (e.g.,
SUM,COUNT,AVERAGE) are fundamental to summarizing data. - Filtering functions like
FILTERand time intelligence functions enhance analytical flexibility.
Final Exam Tips
- If a question mentions interactive reports, dynamic filters, slicers, or time-based comparisons, DAX is likely the right language to use for the solution.
- Measures + CALCULATE + filter context appear frequently.
- If the question mentions slicers, visuals, or dynamic results, think DAX measure.
- Time intelligence functions are high-value topics.
Practice Questions:
Here are 10 questions to test and help solidify your learning and knowledge. As you review these and other questions in your preparation, make sure to …
- Identifying and understand why an option is correct (or incorrect) — not just which one
- Look for and understand the usage scenario of keywords in exam questions to guide you
- Expect scenario-based questions rather than direct definitions
1. Which DAX function is primarily used to modify the filter context of a calculation?
A. FILTER
B. SUMX
C. CALCULATE
D. ALL
Correct answer: ✅ C
Explanation: CALCULATE changes the filter context under which an expression is evaluated.
2. A Power BI report contains slicers for Year and Product. A measure returns different results as slicers change. What concept explains this behavior?
A. Row context
B. Filter context
C. Evaluation context
D. Query context
Correct answer: ✅ B
Explanation: Filter context is affected by slicers, filters, and visual interactions.
3. Which DAX function iterates row by row over a table to perform a calculation?
A. SUM
B. COUNT
C. AVERAGE
D. SUMX
Correct answer: ✅ D
Explanation: SUMX evaluates an expression for each row and then aggregates the results.
4. You want to calculate total sales only for transactions greater than $1,000. Which approach is correct?
A.
SUM(Sales[SalesAmount] > 1000)
B.
FILTER(Sales, Sales[SalesAmount] > 1000)
C.
CALCULATE(
SUM(Sales[SalesAmount]),
Sales[SalesAmount] > 1000
)
D.
SUMX(Sales, Sales[SalesAmount] > 1000)
Correct answer: ✅ C
Explanation: CALCULATE applies a filter condition while aggregating.
5. Which DAX object is evaluated dynamically based on report filters and slicers?
A. Calculated column
B. Calculated table
C. Measure
D. Relationship
Correct answer: ✅ C
Explanation: Measures respond dynamically to filter context; calculated columns do not.
6. Which function is commonly used to calculate year-to-date (YTD) values in DAX?
A. DATESINPERIOD
B. SAMEPERIODLASTYEAR
C. TOTALYTD
D. CALCULATE
Correct answer: ✅ C
Explanation: TOTALYTD is designed for year-to-date aggregations.
7. A DAX measure returns different totals when placed in a table visual grouped by Category. Why does this happen?
A. The measure contains row context
B. The table visual creates filter context
C. The measure is recalculated per row
D. Relationships are ignored
Correct answer: ✅ B
Explanation: Visual grouping applies filter context automatically.
8. Which DAX function returns a table instead of a scalar value?
A. SUM
B. AVERAGE
C. FILTER
D. COUNT
Correct answer: ✅ C
Explanation: FILTER returns a table that can be consumed by other functions like CALCULATE.
9. Which scenario is the best use case for DAX instead of SQL or KQL?
A. Cleaning raw data before ingestion
B. Transforming streaming event data
C. Creating interactive report-level calculations
D. Querying flat files in a lakehouse
Correct answer: ✅ C
Explanation: DAX excels at dynamic, interactive calculations in semantic models.
10. What is the primary purpose of the SAMEPERIODLASTYEAR function?
A. Aggregate values by fiscal year
B. Remove filters from a date column
C. Compare values to the previous year
D. Calculate rolling averages
Correct answer: ✅ C
Explanation: It shifts the date context back one year for year-over-year analysis.

One thought on “Select, Filter, and Aggregate Data Using DAX”