0% found this document useful (0 votes)
38 views27 pages

1706172524-Unit 2.6 - Data Analysis Expressions (DAX)

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)
38 views27 pages

1706172524-Unit 2.6 - Data Analysis Expressions (DAX)

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/ 27

Data Analysis Expressions (DAX)

Data Analysis using Power BI


Data Analysis Expressions (DAX)

Disclaimer
The content is curated from online/offline resources and used for educational purpose only
Data Analysis Expressions (DAX)

Unit – 2.6
Data Analysis Expressions (DAX)
Data Analysis Expressions (DAX)

Learning Objectives

You will learn in this lesson:


• Participant will learn fundamental concepts of
Data analysis Expression.
• Participant will have hands on Creating Calculated
Columns and Measures.
• Participants will learn Aggregation and
Summarization concept in DAX
Data Analysis Expressions (DAX)

Introduction to DAX

• DAX is a collection of functions, operators, and


constants that can be used in a formula, or
expression, to calculate and return one or more
values. DAX helps you create new information
from data already in your model.
• DAX is specifically designed for data modeling
and analysis, and it enables users to perform
complex calculations on data within Power BI
reports and visuals.

Click here

Source: https://k21academy.com/microsoft-azure/data-analyst/data-analysis-expression/
Data Analysis Expressions (DAX)

DAX Calculation Types

• Calculated columns
• Measures

Source: https://www.simplilearn.com/tutorials/artificial-intelligence-tutorial/what-is-artificial-intelligence
Data Analysis Expressions (DAX)

Create Model Calculations by using DAX

• In this example, we'll work with a simple data model containing two tables: "Sales" and "Products." The
"Sales" table contains sales transaction data, and the "Products" table contains information about the
products being sold. Both tables have a common column called "ProductID," which can be used to
establish a relationship between them.
Total Sales:
• This measure calculates the total sales amount from the "Sales" table.
DAX Formula:
Total Sales = SUM(Sales[SalesAmount])
Data Analysis Expressions (DAX)

Create Model Calculations by using DAX

• Total Quantity Sold:


This measure calculates the total quantity of products sold from the "Sales" table.
DAX Formula:
Total Quantity Sold = SUM(Sales[Quantity])
• Average Unit Price:
This measure calculates the average unit price of products sold.
DAX Formula:
Average Unit Price = DIVIDE([Total Sales], [Total Quantity Sold])
• Distinct Products Count:
This measure counts the number of distinct products available in the "Products" table.
DAX Formula:
Distinct Products Count = DISTINCTCOUNT(Products[ProductID])
Data Analysis Expressions (DAX)

Create Model Calculations by using DAX


• Total Revenue by Product:
This measure calculates the total revenue generated for each product.
DAX Formula:
SUMX(<table>, <expression>)
Total Revenue by Product = SUMX(RELATEDTABLE(Sales), Sales[SalesAmount])
• Top Selling Products:
This measure ranks products based on sales amount and returns the top N products.
DAX Formula:
Top Selling Products = TOPN(5, Products, [Total Sales])
• Year-to-Date (YTD) Sales:
This measure calculates the year-to-date sales amount based on the calendar year.
DAX Formula:
YTD Sales = TOTALYTD([Total Sales], 'Date'[Date])
Data Analysis Expressions (DAX)

Create Model Calculations by using DAX

• Month-over-Month Sales Growth:


This measure calculates the percentage change in sales from the previous month.
DAX Formula:
Month-over-Month Sales Growth = DIVIDE( [Total Sales], CALCULATE([Total Sales],
DATEADD('Date'[Date], -1, MONTH)) ) – 1
• DAX CALENDAR function:
The start-date and end-date arguments could be any DateTime value. It returns the table of a single
column with a set of dates.
Syntax:
CALENDAR(<StartDate>,<EndDate>)
Example:
COUTDAYS(CALENDAR(DATE(2020,4,1), DATE(2020,6,5))) //returns 65
Data Analysis Expressions (DAX)

Create Model Calculations by using DAX

• DAX DATEDIFF function:


The DATEDiff function calculates the difference between two dates and returns it in terms of interval
boundaries given specified by the user.
Syntax:
DATEDIFF(<StartDate>,<EndDate>,<Interval>)
Example:
DATEDIFF(DATE(2020,1,1), DATE(2020,1,31), HOUR) //returns 720
DATEDIFF(DATE(2020,1,1), DATE(2020,3,31), DAYS) //returns 90
DATEDIFF(DATE(2020,1,1), DATE(2020,4,31), MONTH) //returns 3
• DAX NOW function:
The function returns the current DateTime value in the standard format.
Syntax:
NOW()
Example:
HOUR(NOW()) //returns 12:00:00AM
Data Analysis Expressions (DAX)

Create Model Calculations by using DAX

• DAX DATEVALUE function:


Converts the given date into a text-to-date-time format.
Syntax:
DATEVALUE(<DateText>)
Example:
DATEVALUE(“1/4/2020”) //returns
DATEVALUE(“20-3-2020”) //returns 1/20/3/2020 12:00:00AM
DATEVALUE(“15-Jan-2020”) //returns15/1/2020 12:00:00 AM
Data Analysis Expressions (DAX)

Create Model Calculations by using DAX

• Time Intelligence Functions


The time intelligence functions allow the user to calculate the time values over a fixed period of time
such as weeks, months, quarters, and years. These functions are mainly used to calculate
aggregation, per data manipulation, and Business Intelligence with the table of dates as input.
• DAX DATESBETWEEN function
The return table contains a column of dates between the start date and the end date.
Syntax:
DATESBETWEEN(<Dates>, <StartDate>, <EndState>)
Example:
CALCULATE(SUM(Sales([Sales Amount]), DATESBETWEEN(Sales[Date], Date(2020,1,1),
Date(2020,3,31)))
Data Analysis Expressions (DAX)

Create Model Calculations by using DAX

• DAX DATEADD function


Returns a table with the columns of dates shifted, either forward or backward, based on the specified
intervals of time.
Syntax:
DATEADD(<Dates>, <Number_of_Intervals>, <Intervals>)
Example:
DATEADD(ProductInventory[InventoryDate],1,YEAR)
• DAX DATESBETWEEN function
The return table contains a column of dates between the start date and the end date.
Syntax:
DATESBETWEEN(<Dates>, <StartDate>, <EndState>)
Example:
CALCULATE(SUM(Sales([Sales Amount]), DATESBETWEEN(Sales[Date], Date(2020,1,1),
Date(2020,3,31)))
Data Analysis Expressions (DAX)

Create Model Calculations by using DAX

• DAX LAST DATE function


returns the last date of the modifications done in the date columns. For example, the command
mentioned below will return the last date when a sale was made.
Syntax:
LASTDATE(<Dates>)
Example:
LASTDATE(Sales[Date])
• DAX ENDOFYEAR function
Syntax:
ENDOFYEAR(<DATES>, [<Year_End_Date>])
Example:
ENDOFYEAR(Start[Date])
Data Analysis Expressions (DAX)

Lab 11 - DAX

Click View

DAX
Data Analysis Expressions (DAX)

DAX Function Types

• DAX functions play an important role in the usage of DAX for data modeling and reporting.
• It is an inbuilt function provided in the DAX language that helps you perform commonly used data
calculations on the Data Model.
• Some of the DAX functions have the same names and functionality as that of Excel functions, however,
they have been modified to use DAX data types and to work with tables and columns.
• DAX functions play an important role in the usage of DAX for data modeling and reporting.
Data Analysis Expressions (DAX)

DAX Function Types

DAX supports the following types of functions.


• DAX Table-Valued Functions
• DAX Date and Time Functions
• DAX Information Functions
• DAX Logical Functions
• DAX Math and Trig Functions
• DAX Other Functions
• DAX Parent and Child Functions
• DAX Statistical Functions
• DAX Text Functions
• DAX Description Structure Functions
Data Analysis Expressions (DAX)

Lab 12 - DAX Function - 1

Click View

DAX Function
Data Analysis Expressions (DAX)

Lab 13 - DAX Function - 2

Click View

DAX Function
Data Analysis Expressions (DAX)

Summary

• Advanced visualization techniques in Power BI


include heat maps, mosaic plots, map
visualizations, and correlogram visualizations. ​
• To create custom visualizations in Power BI, you
can use the developer tools to create your own
custom visuals or download custom visuals from
the Microsoft AppSource marketplace. ​
• Microsoft Learn provides a comprehensive
reference for creating custom visuals in Power BI. ​
• You can also find a learning path on Microsoft
Learn that covers advanced data visualization
techniques in Power BI​
Data Analysis Expressions (DAX)

QUIZ Let’s Start


Data Analysis Expressions (DAX)

Quiz

1. What does DAX stand for in Power BI?

a) Data Analysis Expressions


b) Data Aggregation Extension
c) Dynamic Analysis Xpression
d) Data Access Execution

Answer: a
Data Analysis Expressions
Data Analysis Expressions (DAX)

Quiz

2. What is the primary purpose of a DAX calculated


column in Power BI?

a) To filter data based on specific conditions


b) To perform advanced data transformations
c) To create custom calculations within a table
d) To establish relationships between tables

Answer: c
To create custom calculations within a table
Data Analysis Expressions (DAX)

Quiz

3. Which DAX function is used to calculate the


average of values in a column, excluding blank
values?

a) SUMX
b) COUNT
c) AVERAGE
d) AVERAGEX

Answer: d
AVERAGEX
Data Analysis Expressions (DAX)

Reference

• https://learn.microsoft.com/en-us/dax/sumx-function-dax
• https://learn.microsoft.com/en-us/dax/dax-function-reference
• https://www.freepik.com/
Data Analysis Expressions (DAX)

Thank you!

You might also like