0% found this document useful (0 votes)
17 views14 pages

Introduction To DAX

DAX, or Data Analysis eXpressions, is a formula language used in Power BI for creating columns, tables, and measures, similar to how formulas are used in Excel. It includes over 200 functions categorized into various types and allows for dynamic analysis through row, filter, and query contexts. Key concepts include calculated columns and measures, as well as the use of the CALCULATE function to evaluate expressions with specific filter contexts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views14 pages

Introduction To DAX

DAX, or Data Analysis eXpressions, is a formula language used in Power BI for creating columns, tables, and measures, similar to how formulas are used in Excel. It includes over 200 functions categorized into various types and allows for dynamic analysis through row, filter, and query contexts. Key concepts include calculated columns and measures, as well as the use of the CALCULATE function to evaluate expressions with specific filter contexts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Introduction to DAX

Debangshu Chatterjee 1
What is DAX?
• DAX stands for Data Analysis eXpressions

• A formula language used in Power BI that provides the ability to create columns, tables, and measures.

• DAX is to Power BI, what formulas are to Excel

• It is used in other Microsoft tools including Analysis Services and Power Pivot.

Debangshu Chatterjee 2
DAX functions
• Functions are predefined formulas that perform calculations on specific values, called arguments, in a
particular order.

• Each function has a specific syntax indicating the order of arguments to be expected.

• DAX has over 200 different functions that fall into several categories, including Aggregation, Date and Time,
Logical, Text, and many more.

Debangshu Chatterjee 3
Calculated Columns and Calculated Measures

Calculated Columns Calculated Measures


For evaluating each row For aggregating multiple rows
Add a new columns to an existing table Results in another field that you can add
to a visualization
Calculated at data load and when the Calculated at query time as you interact
data is refreshed and filter

Debangshu Chatterjee 4
Creating a Calculated Column
• Adventure Works Cycles

• Understand Yearly Profit

• We want to create a Profit column to understand how much profit for each order line

• Profit = (Price – Cost)

• Create a clustered column chart Profit vs OrderDate

Debangshu Chatterjee 5
Creating a Calculated Measure
• Create a table _Calculations

• Create a new Measure SalesCount

• Use DISTINCTCOUNT() function on OrderNo

• Create a Line Chart showing SalesCount by OrderDate

Debangshu Chatterjee 6
Profit Margin Ratio
• Compares the Total Profit to the Total Sales

• Important Financial metric

• It is expressed as a percentage

• Create Measure in _Calculations: TotalProfit = SUM(Sales[Profit])

• Create Measure in _Calculations: TotalSales = SUM(Sales[LinePrice])

• Create a measure in _Calculations: ProfitMarginRatio= DIVIDE([TotalProfit],[TotalSales])

• Create Line Chart ProfitMarginRatio by Order Year

Debangshu Chatterjee 7
Context
• Enables dynamic analysis, where the results of a formula change to reflect the selected data

• There are three types of context –


• row,
• filter and
• query

Debangshu Chatterjee 8
Row Context
• Row context can be thought of as "the current row“

• A calculated column is an example of where row context applies.

• Columns
• In a calculated column the context includes the values from all columns within the current row.

• Row context can also be used in measures, however only when using iterator functions.

Debangshu Chatterjee 9
Row Context
• Measures

• Row context can also be used in measures, however only when using iterator functions.

• An iterator function can be identified by an X at the end of a function name. SUMX()

• Syntax: SUMX(<table>, <expression>)

• Example: SUMX(Sales[Price], (Sales[Price] * Sales[Tax]))

Debangshu Chatterjee 10
Filter Context
• Filter context is a set of filters that have been applied before the calculation is carried out.

• They can be applied in several ways, including


• attributes in a row or column,
• via a slider,
• through the filter pane, or
• in a calculated measure.

• In order for Power BI to return a value for color blue, it will go to the base table and apply a filter
where color is equal to blue. This is the filter context. It is applying the filter context on each quantity
returned by color.

Debangshu Chatterjee 11
Filter Context

• Filtered based on Color and Product Category

Debangshu Chatterjee 12
Calculate Function

• Calculate allows you to evaluate an expression with one or more filter contexts.

• calculate functions takes two arguments - one argument is required and the other argument is
optional.

• The first argument contains the expression to be evaluated - this must return a single value

• The second argument for adding filters is optional - but you need to ensure that filters evaluate as a
table, and do not clash with one another.

• The filters inside the CALCULATE() function will always override any filters from a visualization.

Debangshu Chatterjee 13
Email Id: [email protected]
Contact Number: +919971366473
Debangshu Chatterjee 14

You might also like