You are on page 1of 16

Power BI Class Five

James Stratton

November 20, 2021


Plan for Today Updating in Excel Updating with DAX Finishing Up

Plan for Today

Today, we are working on changing data in Power BI


There are two ways to change data
1 Download the data, change in Excel, then upload back to Power BI
2 Change in Power BI directly, using DAX, the language of Power BI

Today we will be using data from loan applications

1 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

Getting Familiar with Data


To get started, try making these visualizations . . .

2 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

New visualization

What if we wanted to make the visualization below?

3 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

Updating Data

Make the change to the Excel file


Change the source in Power BI

4 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

Change Source

5 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

Change Source

6 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

Introduction to DAX

Data Analysis Expressions DAX is the language of Power BI


Think of it like the formulas you use in Excel
Goal for our lessons
7 Learn every command in DAX
3 Learn how DAX works
3 Learn a few important commands in DAX
3 Know enough about DAX to Google what we don’t know

7 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

Things we can do with DAX


There are three things we can do with DAX . . .

But they all follow the same rules


Today: new columns
Tomorrow: new measures
8 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

The Structure of DAX

When we add a new column, a formula bar appears

On the left is the name of the column we’re creating


Then there is an equals sign
After the equals sign, we type the expression/formula we want to use

9 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

The Structure of DAX

We have education cost in total, and number of students in each


household
Imagine that we wanted to calculate education cost per student
The formula would be . . .
EducCosts = ’My Data’[Cost per year for all students]/’My Data’[Number
of students]
What do you notice?
§ The table name is in speech marks ’ ’
§ The column name is in brackets [ ]
§ Everything else is like Excel!

10 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

Some Simple Formulas in DAX

Most simple formulas are the same as Excel: `, ´, ˆ, ˜


Calculate the following variables:
§ Total revenue per person
§ Number of family members who are not students
§ Profit per acre (i.e. revenue per acre - costs per acre)
Make a card (remember from last week?) to show me your average
for each of these
§ If you have time, add a slicer by village!

11 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

Some Simple Formulas in DAX: ‘if’


The command ‘if’ is very similar to Excel
Imagine we want to know: do people who have been customers for a
long time spend more or less on total family costs?

Make a new called ‘Over Five Loans’ that is ‘Yes’ if Loan Count is at
least 5, and ‘No’ if Loan Count is less than 5
Do it the same way as you would in Excel!
12 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

Some Simple Formulas in DAX: dates


The command ‘TODAY()’ gives today’s date
You can subtract two dates from one another to get the gap between
them
Sometimes this doesn’t work – you have to times it by one to tell
DAX you want a number!
For example, say we want to make a variable which is days since
disbursement
Our first guess might be . . .
Days Since Disbursed = TODAY() - ‘My Data’[DisbursedDate]
This does not work!
Let’s try . . .
Days Since Disbursed = 1*(TODAY() - ‘My Data’[DisbursedDate])
13 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

Some Simple Formulas in DAX: dates


Try to make a visualization like the below . . .

You will need to use a formula to create a column for days until due!
14 / 15
Plan for Today Updating in Excel Updating with DAX Finishing Up

Finishing Up

Last bit of practice: can you make the graphs you’ve made today into
a Dashboard?

15 / 15

You might also like