Next

Introduction to DAX

  • Learn the fundamentals of DAX for creating calculations in Power BI.
  • What is DAX?

    DAX (Data Analysis Expressions) is a formula language used to create:

    • Measures

    • Calculated Columns

    • Calculated Tables

    In simple words:
    DAX is the calculation engine of Power BI.

    Why Do We Need DAX?

    Basic visuals can sum numbers automatically.
    But business needs advanced logic like:

    • Profit Margin %

    • Year-over-Year Growth

    • Running Total

    • Conditional KPIs

    • Ranking

    For this, we use DAX.

    Example of Simple DAX Measure

Total Sales = SUM(Sales[SalesAmount])
  • Example: Profit

Profit = SUM(Sales[Sales]) - SUM(Sales[Cost])
  • Types of DAX Calculations

    Measures

    • Most important

    • Calculated at report level

    • Dynamic (change with filters)

    Example:
    Total Sales

    Calculated Columns

    • Created inside table

    • Row-by-row calculation

    • Stored in memory

    Example:
    Full Name = FirstName & " " & LastName

    Calculated Tables

    • New table created using DAX


    How DAX Works

    Understanding how DAX works is key to mastering it.

    DAX works based on Context.

    Two Important Concepts

    Row Context

    Row context means calculation happens row by row.

    Example (Calculated Column):

Total Price = Sales[Quantity] * Sales[UnitPrice]
  • Each row multiplies Quantity × UnitPrice.

    Filter Context

    Filter context means calculation changes based on filters.

    Example:

    If user selects:
    Region = Gujarat

    Then:

Total Sales = SUM(Sales[SalesAmount])
  • Will show sales only for Gujarat.

    This is why Measures are powerful.

    How DAX Executes

    When you add a measure to a visual:

    1. Power BI checks applied filters

    2. Applies filter context

    3. Calculates result

    4. Displays output

    Every interaction (slicer, click, drill) recalculates DAX.

    Aggregation Functions

    Common DAX functions:

    • SUM()

    • COUNT()

    • DISTINCTCOUNT()

    • AVERAGE()

    • MIN()

    • MAX()

    Logical Functions

    • IF()

    • SWITCH()

    • AND()

    • OR()

    Example:

Sales Category =
IF(SUM(Sales[Sales]) > 100000, "High", "Low")
Next