0% found this document useful (0 votes)
70 views13 pages

Exemplar Adding A Calculated Table and Column

The document provides a step-by-step guide for creating calculated tables and columns in Power BI using DAX, focusing on data standardization and consistency. It outlines tasks such as downloading the Adventure Works dataset, removing duplicates, setting table relationships, and adding calculated columns. The guide includes DAX code examples and emphasizes the importance of correct formatting and matching column names.

Uploaded by

ebadmohdhusain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views13 pages

Exemplar Adding A Calculated Table and Column

The document provides a step-by-step guide for creating calculated tables and columns in Power BI using DAX, focusing on data standardization and consistency. It outlines tasks such as downloading the Adventure Works dataset, removing duplicates, setting table relationships, and adding calculated columns. The guide includes DAX code examples and emphasizes the importance of correct formatting and matching column names.

Uploaded by

ebadmohdhusain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Exemplar Adding a calculated table

and column
Overview
In the exercise Adding a calculated table and column, you were asked to create new calculated
tables and columns using DAX within your data model to address specific analytical and
visualization concerns.

Your tasks in this exercise were to:

 Create a calculated table from the existing dataset within your data model.
 Add calculated columns to a specific table within the dataset.
 Ensure data standardization and consistency.

This reading provides you with a step-by-step guide for completing these tasks. It also includes
screenshots that you can compare against your work.

You can also review the Introduction to calculated tables and Creating calculated columns videos
for guidance on using DAX in Power BI.

Step 1: Download and connect to the Adventure


Works Dataset.
1. Download the workbook from the exercise page on the Coursera platform.
1. Launch Power BI desktop. To create a new project, select the File menu, then select
New. Import the Adventure Works dataset that you have downloaded. In the Home tab,
select the Get Data drop-down menu. Then select an appropriate data source. For the
current exercise, select Excel Workbook and navigate to the Adventure Works
dataset folder.

3. Once you select and load the data, Power BI opens a Navigator dialog box that lists all the
tables available to load in the Excel file, along with the data preview on the right side of the
Navigator. Select the Sales, Product, Region, Date, and Salesperson tables, then
select Load.
Step 2: Remove all duplicate values and set the
relationships between the tables.
1. To eliminate all duplicate data, access the Power Query editor, right-click on the
SalesOrderNumber columns, and select Remove duplicates from the drop-
down menu.
1. To configure the model relationships, access the Model view of Power BI desktop and
select Manage relationships. From here, you can edit cardinality and cross-filter
direction between the tables.
Step 3: Create a calculated table.
1. Access the Model view in the calculations group to create a new table. Select New
table. Copy and paste the following DAX code into the formula bar:

5
2
3
4
1
"Color", RELATED ( Products[Color]))
ADDCOLUMNS (
Sales,
"Year", RELATED ( 'Date'[Year]),
Yearly Sales by color =
 ADDCOLUMNS: Adds calculated columns to the given table or table expression. In this
instance, the Sales table is the main table to which you need to add two more columns,
one from the Date table and one from the Product table.
 Year and Color in double quotes are the names of the new columns to be added in the
new calculated table.
 RELATED: Returns a related value from another table. In this case, Product color
values from the Product table and Year information from the Date table.
1. Note that the resulting table has 11 columns.
Step 4: Create calculated columns.
1. To create a new column, select the Date table from the Data pane on the right side of
Power BI interface. Access Model view in the Calculations group and select
New column. Copy and paste the following DAX code into the formula bar:

1
Qtr = QUARTER('Date'[Date])
 QUARTER: Returns each quarter as a number from the Date column.
 Date in single quotes is the table, and Date in square brackets is the column within the
table.

1. Select the Date table from the Data pane on the right side of Power BI interface.
Access Model view in the Calculations group and select New column. Copy
and paste the following DAX code into the formula bar:

1
Month =LEFT ( 'Date'[Month], 3 )
 LEFT: Returns the specified number of characters from the start of a text string.
 Date in single quotes is the table to be referenced, and Month in square brackets is
the column name. The number 3 specifies the number of characters in the short month
column.

1. To create a new column, select the Product table from the Data pane on the right
side of Power BI interface. Access Model view in the calculations group. Then
select New column to expand the formula bar. Copy and paste the following DAX
code into the formula bar:

1
Product Color = RELATED ( Products[Color] )
 RELATED here is the same as referencing a column from another table.
Step 5: Save your Power BI project.
 To save the project, open the File menu, select Save As, and provide an appropriate
name for the project along with a path to the folder on your computer.

Conclusion
With these steps, you have successfully created a calculated table by combining data from
multiple datasets and user-defined columns using DAX. You can now analyze Adventure Works
data based on the analytical and business requirements.

Remember that when using DAX formulas, always ensure they are correctly formatted and that
the column names match the actual column names in your data.

You might also like