DEV Community

Philemon Adaghe
Philemon Adaghe

Posted on

✅ *Power BI DAX Basics

Power BI DAX Basics 📊🧠

DAX (Data Analysis Expressions) is the formula language in Power BI. It's used to create custom calculations, measures, and calculated columns.

1️⃣ SUM()

Adds up values from a column

Example:

Total Sales = SUM(Sales[Amount])

2️⃣ AVERAGE()

Calculates the average of a column

Example:

Avg Salary = AVERAGE(Employee[Salary])

3️⃣ COUNT(), COUNTA(), COUNTROWS()

  • COUNT() – counts numeric values
  • COUNTA() – counts non-blank values
  • COUNTROWS() – counts rows in a table Examples: Total Orders = COUNT(Orders[OrderID]) Total Customers = COUNTROWS(Customers)

4️⃣ CALCULATE()

Modifies the context of a calculation

Example:

Sales East = CALCULATE(SUM(Sales[Amount]), Sales[Region] = "East")

5️⃣ FILTER()

Creates a filtered table for use inside CALCULATE

Example:

High Sales = CALCULATE(SUM(Sales[Amount]), FILTER(Sales, Sales[Amount] > 1000))

6️⃣ IF()

Adds logic to DAX

Example:

Sales Category = IF(Sales[Amount] > 500, "High", "Low")

7️⃣ SWITCH()

Simpler alternative to nested IFs

Example:

Rating = SWITCH(TRUE(),
 [Score] >= 90, "A",
 [Score] >= 75, "B",
 [Score] >= 60, "C",
 "Fail"
)
Enter fullscreen mode Exit fullscreen mode

8️⃣ ALL()
Removes filters from a column or table

Example:

% of Total = DIVIDE(SUM(Sales[Amount]), CALCULATE(SUM(Sales[Amount]), ALL(Sales)))

9️⃣ DISTINCT()

Returns unique values in a column

Example:

Unique Products = DISTINCT(Sales[Product])

🔟 Measures vs Calculated Columns

  • Measure: Calculated based on report context (preferred for visuals)
  • Calculated Column: Stored in the data model, row-by-row logic

💬

Top comments (0)