0% found this document useful (0 votes)
64 views

Chapter 1

The document introduces DAX (Data Analysis Expressions) which is a formula language used to create calculations in Power BI. It discusses DAX functions like SUM() and LEFT() which perform calculations on specific values called arguments. It explains that calculated columns evaluate at a row level to add new columns, while calculated measures aggregate multiple rows to add new fields for visualizations. Calculated columns are calculated at data load, while measures are calculated at query time.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Chapter 1

The document introduces DAX (Data Analysis Expressions) which is a formula language used to create calculations in Power BI. It discusses DAX functions like SUM() and LEFT() which perform calculations on specific values called arguments. It explains that calculated columns evaluate at a row level to add new columns, while calculated measures aggregate multiple rows to add new fields for visualizations. Calculated columns are calculated at data load, while measures are calculated at query time.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Introduction to DAX

in Power BI
I N T R O D U C T I O N TO DA X I N P OW E R B I

Jess Ahmet
Content Developer, DataCamp
What is DAX?
Data Analysis eXpressions

Formula language to create calculations


Columns, tables, measures

Based on Excel formulas and functions


e.g., SUM()

Used in other Microso tools


Power Pivot and Analysis Services

INTRODUCTION TO DAX IN POWER BI


DAX functions
Prede ned formulas that perform calculations on speci c values called arguments

Function syntax indicates the order of arguments expected

Function categories
Aggregation - SUM() , AVERAGE() , COUNT()

Date and Time - TODAY() , MONTH() , YEAR()

Logical - IF() , AND() , OR()

Text - CONCATENATE() , UPPER() , LEFT()

And many more...

DAX reference:
h ps://docs.microso .com/en-us/dax/dax-function-reference

INTRODUCTION TO DAX IN POWER BI


DAX functions example
SUM() LEFT()
Syntax: SUM(<column>) Syntax: LEFT(<text>, <num_chars>)

Description: Adds all the numbers in a Description: Returns the speci ed


column. number of characters from the start of a
text.
One argument: <column>
Two arguments: <text> , <num_chars>
Example: SUM(Sales)
Example: LEFT('DataCamp', 4) = "Data"

INTRODUCTION TO DAX IN POWER BI


Creating calculated columns
Expands our existing datasets without editing the source data

Evaluates at a row level and adds a new column to an existing table

Calculated at data load or when the data is refreshed

INTRODUCTION TO DAX IN POWER BI


Creating calculated columns
Expands our existing datasets without editing the source

Evaluates at a row level and adds a new column to an existing table

Calculated at data load and when the data is refreshed

DAX example: Price_w_tax = Price + ( Price * Tax )

Item Price Tax


A $ 20 25%
B $ 45 0%
C $ 100 15%

INTRODUCTION TO DAX IN POWER BI


Creating calculated columns
Expands our existing datasets without editing the source

Evaluates at a row level and adds a new column to an existing table

Calculated at data load and when the data is refreshed

DAX example: Price_w_tax = Price + ( Price * Tax )

Item Price Tax Price_w_tax


A $ 20 25% $25
B $ 45 0% $45
C $ 100 15% $115

INTRODUCTION TO DAX IN POWER BI


Creating calculated measures
Enables complex calculations

Aggregates multiple rows and adds a new eld that can be added to visualizations

Calculated at query time as you interact and lter


More e cient because the calculation is not run every time the table is accessed

Two ways to create a measure


Write a measure from scratch

Use the built-in Quick Measure tool

INTRODUCTION TO DAX IN POWER BI


Creating calculated measures
Item Price Tax Price_w_tax
A $ 20 25% $25
B $ 45 0% $45
C $ 100 15% $115
Total_price_w_tax = SUM(Price_w_tax)

Total_price_w_tax = $25 + $45 + $115 = $185

INTRODUCTION TO DAX IN POWER BI


Summary
Calculated columns: Calculated measures:
Evaluate for each row

Add a new column to an existing table

Calculated at data load or when the data is


refreshed

INTRODUCTION TO DAX IN POWER BI


Summary
Calculated columns: Calculated measures:
For evaluating each row For aggregating multiple rows

Add a new column to an existing table Results in another eld that you can add to
a visualization
Calculated at data load or when the data is
refreshed Calculated at query time as you interact
and lter
Item Price Tax Price_w_tax
Total_price_w_tax = SUM(Price_w_tax)
A $ 20 25% $25
B $ 45 0% $45
C $ 100 15% $115

INTRODUCTION TO DAX IN POWER BI


Summary
Calculated columns: Calculated measures:
For evaluating each row For aggregating multiple rows

Add a new column to an existing table Results in another eld that you can add to
a visualization
Calculated at data load and when the data
is refreshed Calculated at query time as you interact
and lter
Item Price Tax Price_w_tax
Total_price_w_tax = SUM(Price_w_tax)
A $ 20 25% $25
B $ 45 0% $45
C $ 100 15% $115

1 Calculated tables will be covered later.

INTRODUCTION TO DAX IN POWER BI


Adventure Works
Sells bikes and bike-parts globally

Table: Sales
Transactional data for each order line of
a sale

Contains categorical data including


product category

INTRODUCTION TO DAX IN POWER BI


Let's practice!
I N T R O D U C T I O N TO DA X I N P OW E R B I
Creating calculated
columns and
measures
I N T R O D U C T I O N TO DA X I N P OW E R B I

Jess Ahmet
Content Developer, DataCamp
Let's practice!
I N T R O D U C T I O N TO DA X I N P OW E R B I

You might also like