Cloning and Calculating Tables
Cloning and Calculating Tables
Introduction
As data analysts, one of the most crucial tools in your arsenal is Microsoft PowerBI. It is a
powerful software that can transform raw data into meaningful insights. Data analysts must be
familiar with two fundamental concepts: cloning tables and using calculated tables.
Understanding these concepts can significantly improve your proficiency in data analysis and
visualization. In this article, you’ll review these concepts using real-world examples.
Scenario
Adventure Works collects vast amounts of data from various sources. The company wants to
gain insights from this data to target its marketing campaigns more efficiently, monitor the
performance of its sales teams, and establish greater inventory control. To achieve this, it must
clone the data tables from its central data warehouse and create new tables from the existing
data to answer specific business and analytical questions. Review the steps Adventure Works
can take to complete these actions.
Profitability Analysis
By creating a calculated table for profitability analysis, you can draw insights into gross margins,
net profits, and profit margins. This helps organizations identify their most profitable products,
categories, services, and customer segments.
Customer Segmentation
Understanding customer behavior is crucial for marketing efforts. You can create a calculated
table with DAX to facilitate customer segmentation based on transaction history. This helps
businesses to tailor their marketing strategies for each customer segment.
Use Variables
Using variables is an excellent way to enhance formula readability. Variables are recommended
wherever you need to write a complex expression. By defining variables, you can avoid repeating
the same expression.
Take the following expression, which aims to calculate the sales growth of Adventure Works as
an annual percentage:
This formula repeats the expression same period last year. It can be made more efficient by
introducing a variable called SalesPriorYear as follows:
1
2
3
4
5
Sales YoY Growth % = VAR SalesPriorYear =
CALCULATE ( [Sales],
PARALLELPERIOD ( 'Date'[Date], -12, MONTH ) )
RETURN
DIVIDE ( ( [Sales] - SalesPriorYear ), SalesPriorYear )
Variables are useful to improve code readability, better performance, and easier debugging.
Format DAX syntax
Formatting DAX formulas and expressions is crucial for maintaining consistency and readability.
When working in a team, format your syntax to enhance comprehension and simplify
troubleshooting. For example, consider the following syntax:
The syntax is complex. It contains many arguments and is hard to comprehend. On formatting
the syntax, it looks like this:
Total Revenue =
CALCULATE
( SUM ( Sales[Revenue] ),
FILTER ( Sales, Sales[OrderDate] = 2018
&&
Sales[Product Color] = "Blue" ))
It became instantly readable, easy to follow along with each function, and the argument is broken
down into a new line. Using line breaks and tabs makes the syntax comprehensible and is
especially important when working in a team.
Conclusion
Powered by DAX in Power BI, calculated tables enhance data analysis by providing a flexible
and powerful tool for creating custom tables with calculated values.
They offer benefits like time intelligence functions, profitability assessment, and customer
segmentation. Use these benefits to generate real-world insights into the hidden values of the
datasets.
By mastering DAX, you can unleash the full potential of data and gain a competitive advantage in
today’s data-centric business landscape.