Table of contents
Upskilling Made Easy.
Introduction to DAX and Measures in Power BI
Published 05 May 2025
1.5K+
5 sec read
Welcome to the world of Data Analysis Expressions (DAX)! If you're navigating the seas of Power BI for business analysis, understanding DAX is like having a compass guiding you through. This blog covers what DAX is, how measures work, and explores a plethora of DAX functions from beginner to pro level.
Data Analysis Expressions (DAX) is a formula language used in Power BI, Excel, and other Microsoft tools. It helps you create calculated columns, measures, and calculate values on the fly. DAX enables you to manipulate and analyze data with precision, empowering you to derive meaningful insights.
Quirky Insight: Think of DAX as the secret sauce that enhances the flavor of your data analysis—it might seem simple, but it packs a punch!
Measures in Power BI are DAX calculations that aggregate data in real-time as users interact with the report. They are often used for analysis, allowing dynamic calculations based on the current filter context.
Total Sales = SUM(Sales[SalesAmount])
This measure sums up the total sales amount from the Sales table.
DAX Functions Overview Let’s explore some of the most commonly used DAX functions across various skill levels:
SUM: Adds up all the values in a column. Total Sales = SUM(Sales[SalesAmount])
AVERAGE: Calculates the average of a column. Average Sales = AVERAGE(Sales[SalesAmount])
COUNT: Counts the number of rows in a column. Total Transactions = COUNT(Sales[TransactionID])
COUNTA: Counts all non-empty values in a column. Total Products = COUNTA(Products[ProductID])
MIN: Returns the smallest value in a column. Minimum Sale = MIN(Sales[SalesAmount])
MAX: Returns the largest value in a column. Maximum Sale = MAX(Sales[SalesAmount])
DISTINCTCOUNT: Counts the number of distinct values in a column. Unique Customers = DISTINCTCOUNT(Sales[CustomerID])
IF: Performs a conditional check. Sales Performance = IF(SUM(Sales[SalesAmount]) > 1000, "Good", "Needs Improvement")
SWITCH: Evaluates multiple conditions and returns a corresponding value. Sales Category = SWITCH(TRUE(), SUM(Sales[SalesAmount]) > 1000, "High", SUM(Sales[SalesAmount]) > 500, "Medium", "Low" )
CALCULATE: Changes the context in which a data expression is evaluated. Sales 2020 = CALCULATE(SUM(Sales[SalesAmount]), Sales[Year] = 2020)
FILTER: Filters a table based on a condition. High Value Sales = FILTER(Sales, Sales[SalesAmount] > 1000)
RETURN SUM(Sales[SalesAmount]) - PreviousSales
RANKX: Ranks items in a table based on a specified expression.
Sales Rank = RANKX(ALL(Products[ProductName]), SUM(Sales[SalesAmount]))
TOPN: Returns the top N rows of a table based on a specified expression.
Top 5 Products = TOPN(5, Products, [Total Sales], DESC)
CALENDAR: Creates a table with continuous dates for the specified period.
Dates = CALENDAR(MIN(Sales[Date]), MAX(Sales[Date]))
YEARFRAC: Calculates the year fraction between two dates.
Year Fraction = YEARFRAC(Sales[StartDate], Sales[EndDate])
NOW: Returns the current date and time.
Current Time = NOW()
EOMONTH: Returns the last day of the month, for a specified number of months before or after.
End Of Month = EOMONTH(Sales[Date], 0)
PREVIOUSMONTH: Returns a table that contains all the dates from the previous month.
Previous Month Sales = CALCULATE(SUM(Sales[SalesAmount]), PREVIOUSMONTH(Sales[Date]))
CONCATENATEX: Concatenates the values of a column in a table into a single string.
Concatenated Products = CONCATENATEX(Products, Products[ProductName], ", ")
UNION: Combines two or more tables into a single table.
Combined Sales = UNION(Sales_2020, Sales_2021)
EXCEPT: Returns the difference between two tables.
Unique Customers = EXCEPT(VALUES(Customers[CustomerID]), VALUES(PreviousYear[CustomerID]))
INTERSECT: Returns the common rows from two tables.
Common Customers = INTERSECT(VALUES(CurrentYear[CustomerID]), VALUES(PreviousYear[CustomerID]))
NOT: Returns TRUE if the argument is FALSE, otherwise it returns FALSE.
Not Sold Products = CALCULATE(COUNTROWS(Products), NOT(Products[Sold] = TRUE))
SUMX: Evaluates an expression for each row in a table and returns the sum of those values.
Total Sales X = SUMX(Sales, Sales[SalesAmount] * Sales[Quantity])
AVERAGEX: Returns the average of an expression evaluated for each row in a table.
Average Sales X = AVERAGEX(Sales, Sales[SalesAmount] * Sales[Quantity])
CALCULATETABLE: Evaluates a table expression in a modified filter context.
Filtered Sales = CALCULATETABLE(Sales, Sales[SalesAmount] > 1000)
VALUES: Returns a one-column table that contains the distinct values from the specified column.
Distinct Products = VALUES(Products[ProductName])
ISBLANK: Checks whether a value is blank.
Is No Sales = IF(ISBLANK(SUM(Sales[SalesAmount])), "No Sales", "Sales Available")
USERELATIONSHIP: Specifies an alternative relationship to use in a calculation.
Alternate Relationship = CALCULATE(SUM(Sales[SalesAmount]), USERELATIONSHIP(Sales[AlternateKey], Products[ProductKey]))
DISTINCT: Returns a one-column table that contains the distinct values from the specified column.
Unique Products = DISTINCT(Sales[ProductID])
LOOKUPVALUE: Returns the value of a proposed column by searching for a specified value in another column.
Product Price = LOOKUPVALUE(Products[Price], Products[ProductID], Sales[ProductID])
RATIO: Calculates the ratio of two values.
Sales Ratio = DIVIDE(SUM(Sales[SalesAmount]), SUM(Sales[Cost]),0) // Returns 0 if the denominator is 0
DATEADD: Returns a table that contains dates shifted by a specified number of intervals.
Sales Last Year = CALCULATE(SUM(Sales[SalesAmount]), DATEADD(Date[Date], -1, YEAR))
PARALLELPERIOD: Returns a table that contains a column of dates, shifted either back or forward in time.
Sales Same Month Last Year = CALCULATE(SUM(Sales[SalesAmount]), PARALLELPERIOD(Date[Date], -1, MONTH))
CLOSINGBALANCE: Returns the closing balance of a measure at the end of the specified period.
Closing Balance = CLOSINGBALANCE(Sales[SalesAmount], Dates[Date])
OPENINGBALANCE: Returns the opening balance of a measure at the beginning of the specified period.
Opening Balance = OPENINGBALANCE(Sales[SalesAmount], Dates[Date])
In summary, DAX is a powerful tool in Power BI that enables you to perform robust data analysis. By mastering a variety of DAX functions, you can create insightful measures to drive your business analysis forward. Remember, practice is key! The more you explore and utilize DAX functions, the more proficient you'll become in crafting meaningful narratives from your data.
Inspirational Quote: "It is a capital mistake to theorize before one has data." — Arthur Conan Doyle
Happy DAXing! Stay curious and keep extracting insights from your data! 📊