Exercise Adding a calculated table and column
Exercise Adding a calculated table and column
column
Introduction
You should now understand how to use DAX formulas and functions in Power BI to create
calculated tables and columns.
In this exercise, you’ll apply your knowledge of DAX to add a calculated table and column to an
existing dataset.
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.
Scenario
Adventure Works needs your help to analyze its sales data to generate insights into its sales
performance. However, you must analyze the company’s data without altering the original
dataset. You must also create summary tables and normalize dimension tables for analysis.
The company provides you with an Excel workbook called AdventureWorksData.xlsx. You must
download this file and load it to Power BI to complete your assigned task. Be sure to evaluate the
data quality and configure the model to ensure that Adventure Works can use it to make
informed decisions.
AdventureWorksData
XLSX File
Instructions
Create a new Power BI project called Exercise – Adding a calculated column and table. Follow
the steps below to complete the exercise.
Tip: You can import data using the Get Data drop-down menu.
Step 2: Remove all duplicate values and set the relationships between
the tables.
1. Remove all duplicate values from the SalesOrderNumber column of the Sales fact
table.
2. Ensure that one-to-many relationships exist between the fact table and all dimension
tables. Once you load the data, Power BI will establish the table relationships
automatically. If any relationship is missing, create it manually.
Tip: You can view and configure model relationships in Model view of Power BI
desktop. You can create and edit relationships in Manage Relationship view of
Power BI desktop.
Tip: Create the calculated table using the ADDCOLUMNS and RELATED DAX
functions. ADDCOLUMNS: Adds calculated columns to the given table or table
expression. You can add columns to the Sales table from the Date and Product table.
Syntax: ADDCOLUMNS(<table>, <name>, <expression>[, <name>,
<expression>]…) RELATED: Returns a related value from another table. You need to
use this function to add Product color from the Product table and Year
information from the Date table to the Sales table to create a new calculated table.
Syntax: RELATED(<column>)
Tip: You can create columns using the New column feature from the table tools tab
of Power BI’s desktop interface, along with the RELATED, MONTH, and QUARTER
DAX functions. You can use the MONTH DAX function to display each month’s name.
Conclusion
By completing these steps, you’ve 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.
When using DAX formulas, always ensure they are correctly formatted and that the column
names match the actual column names in your data.