Introduction to DAX (Data Analysis Expressions)
DAX, or Data Analysis Expressions, is the core formula language in Power BI. It allows you to define powerful custom calculations that go beyond the default aggregations and filtering options available in visuals.
Just like Excel formulas, DAX is designed to create values dynamically based on your data model. But unlike Excel, DAX works with relational models, respects row and filter context, and enables dynamic expressions that respond to slicers and visuals in real-time.
⚙️ Why is DAX Important?
- Build custom KPIs and metrics like Profit Margin, CLV, Year-over-Year comparisons
- Create dynamic reports that respond to filters, date ranges, and slicers
- Aggregate data across related tables with cross-table logic
- Build time-intelligence logic like YTD, QTD, running totals, previous year, etc.
🎯 Example Need: Imagine you want to calculate Profit % as Profit ÷ Revenue
, but only for the filtered time period selected in the slicer. This is only possible using a DAX Measure.
📘 What Can You Do with DAX?
- Calculated Columns: Add new fields in your tables using row-level logic
- Measures: Create visual-driven aggregations that update dynamically
- Calculated Tables: Build new tables using queries, filters, and joins
💡 Tip: Use Calculated Columns for categorizing data, Measures for aggregating metrics, and Tables for building new model relationships or slicers.
🔍 Understanding Context in DAX
DAX calculations depend heavily on two types of context:
- Row Context: The current row in the table (used in Calculated Columns)
- Filter Context: The applied filters from visuals, slicers, or report-level filters (used in Measures)
Mastering DAX means mastering how these contexts interact — and how to override or use them wisely.
📌 Where Do You Write DAX?
- Data View: For Calculated Columns and Tables
- Model View: For Measures and DAX Tables
- Report View: Create Measures directly within visuals
📎 Before You Begin Writing DAX
- Ensure your data model has proper relationships
- Use clear table and column naming conventions
- Start with simple calculations and gradually add complexity
- Learn how to debug and test with sample visuals or cards
✅ Now that you understand what DAX is and why it matters, let’s explore its three building blocks:
- Calculated Columns – row-based logic stored in tables
- Measures – dynamic metrics that respond to visuals and filters
- Calculated Tables – reusable tables created using DAX queries