Importance of Data Analysis Expressions (DAX) in Power BI
DAX stands for Data Analysis Expressions, a formula language used in Power BI, Excel, and SQL Server Analysis Services to perform calculations on data. DAX is a library of operators and functions which can be combined for building formulas and expressions. Think of DAX as a set of instructions that instruct software how to compute values, similar to how you use formulas in Excel to add or subtract numbers.
DAX enables users to perform sophisticated data analysis and modelling, enhancing the insights that can be derived from a dataset. The DAX language is being used in various domains such as:
- Finance: It can model and simulate financial time series, such as the DAX index and USO ETF, providing accurate approximations of market behaviour (Neri & García- Magariño, 2020).
- Business Intelligence: In Power BI, DAX is used alongside M formula language for data transformation, visualization, and complex calculations, greatly enhancing interactive reporting capabilities ( Naneva & Stefanova, 2022).
- Biomedical Research: DAX-1 (NR0B1 gene) is studied for its role in conditions like Adrenal Hypoplasia Congenita and Dosage Sensitive Sex Reversal. Additionally, DAX1 inhibitors, such as flavonoids, are being explored as potential therapeutic agents against Ewing Sarcoma ( Riedstra & Tzagarakis-Foster, 2021; Muhammad Yasir et al., 2023).
Importance of DAX in Power BI
DAX is a key feature in Power BI that enhances data models with powerful analytical capabilities. It enables users to create custom calculations through calculated columns, measures, and tables, adding depth to data analysis (Mitchell Pearson et al., 2020). With DAX custom equations using various available expressions can be used to derive deeper insights from the data. In Power BI, the concepts of expressions and equations are related to how calculations and data transformations are performed, but they serve different purposes and are used in different contexts.
Expressions
Expressions in Power BI are used as formulas or calculations that produce a value. They are used to create calculated columns, measures, or variables, and they involve operations on data, such as arithmetic operations, logical operations, or function calls.
Total Sales = SUM(Sales[Amount])
This expression calculates the sum of the Amount column in the Sales table.
Equations
An equation in Power BI typically refers to a complete statement that defines a new value or transformation using an equal sign (=
). It is essentially a more formalized or complete form of an expression, where an expression is assigned to a variable, column, or measure.
Total Sales = SUM(Sales[Amount])
Here, Total Sales is a measure that is defined by the equation. The equation sums up the Amount column from the Sales table.
Real-world use cases of DAX
- Financial Reporting: DAX is widely used in financial analysis to create custom metrics such as year-over-year growth, running totals, and profitability ratios.
- Healthcare Data Analysis: In healthcare, DAX can be used to analyze patient data, track treatment outcomes, and manage operational metrics.
- Retail: In retail, it is used to monitor inventory levels, sales trends, and supply chain efficiency. It helps in creating dashboards that display real-time sales data, forecast demand, and optimize inventory management.
- Human Resources: HR departments use it to track employee performance, and turnover rates, and analyse compensation. It helps in generating reports on workforce metrics, such as training effectiveness and employee satisfaction.
- Sustainability Reports: DAX helps track environmental and social performance metrics, such as energy consumption, waste management, and sustainability investments.
- Effort Audit Analytics: DAX can also be used to develop systems that provide insights into user behaviour and data utilization, helping organizations understand how effectively resources are being used and identify areas for improvement (Shayan, 2023).
Introduction to Calculated Columns, Measures, and Calculated Tables
The effectiveness of analysis is enhanced in Power BI through calculated columns, measures, and tables (Mitchell Pearson et al., 2020). These components are essential for creating advanced analytical models and gaining deeper insights from your data.
Calculated Columns are new columns created within a table using DAX. The values in these columns are calculated row by row and stored directly in the data model. Calculated Columns adds a new column to the data table where each cell’s value is calculated based on an equation applied to other columns in the same row. They are useful for adding additional context to the data by performing operations on existing columns (Clark, 2020).
Create a Calculated Column to compute the value of the profit earned product-wise. Choose New Column under Table Tools from the Ribbon in Query Editor.
Now, the formula of profit calculation could be entered. By default the name of the new column is column. You can alter that to your desired name. Enter the equation in this format:
Equation
Profit = 'Store details'[Price]-'Store details'[Production Cost]
Where
Column name = ‘sheet name’ [1st variable name] arithmetic operator ‘sheet name’ [2nd variable name]
Now, a new column is created with the computed profit amount for each row. This column shows how much profit is made per product.
Measures
Measures are dynamic calculations that are performed on-the-fly, based on the context of the data in a report. Unlike Calculated Columns, Measures do not store data in the model but instead compute results based on user interactions, such as filters and slicers. Measures are like live equations that change their results depending on what is currently being viewed in the report, like a dynamic calculator that adjusts its results based on the context. Measures are considered a crucial component of data modelling, as they require a deep understanding of data context and commonly used DAX functions (Clark, 2020). They enable complex calculations such as year-over-year growth, average order values, and KPIs, which adapt based on the report’s current view.
Let’s compute total profit as a new measure.
Now, enter the equation for total profit using the aggregate function SUM. By default, the name of the measure is Measure.
Total Profit = SUM('Store details'[Profit])
This will compute the new measure of Total profit which can be seen on the right side panel but a new column is not added.
This measure aggregates the profit amount. When a new filter for visualization is applied then the amount automatically adjusts.
Calculated Tables
Calculated Tables are created using DAX that are added to the data model. These tables can be used for summarizing, filtering, or analyzing specific segments of data. Calculated Tables are like making a new, smaller table from the main dataset that shows only specific information, such as the top 10 best customers. Calculated Tables are useful for creating summaries or filtered datasets that are not present in the original data model. They help in organizing data for more detailed analysis or reporting.
Let’s create a new table with the details of the top 10 buyers based on the sales amount. For this click on the new table.
Now, enter the equation for the new table. By default the name of the table is Table.
Top Buyers = TOPN(10, 'Buyer information',[Total Purchased],ASC)
Where;
equation = expression(number derived, 'Table name', [Column name], Order ofthe result)
This equation results in the listing of the top 10 buyers from the table Buyer information is based on the total purchase amount is arranged in ascending order.
The right pane shows the addition of a new table named Top Buyers.
Base | Calculated columns | Measures |
---|---|---|
Calculation context | Expand the table by creating a new column. Computed row by row and stored in the data model. | Summarize data into a single value. Computed on the fly based on the context of the data in the report. |
Storage | Stored along with the table. Results are stored in the data model, increasing the model’s size but allowing for quick access. | Results are not stored but calculated in real-time, which can improve performance with large datasets. |
Memory usage | Consumes memory | Stored temporarily |
Usage | Best for transformations and static calculations that need to be part of the data model. | Ideal for aggregations and calculations that need to respond to report filters and slicers. |
Analytical capability | Less | High |
DAX uses different arithmetic symbols to perform arithmetic operations. Some of these are given below.
Type | Symbol | Operation |
---|---|---|
Parathesis | () | Precedence order and grouping of arguments |
Arithmetic | + | Addition |
– | Subtraction | |
* | Multiplication | |
/ | Division | |
^ | Exponentiation | |
Comparison | = | Equal to |
> | Greater than | |
< | Less than | |
>= | Greater than or equal to | |
<= | Less than or equal to | |
<> | Not equal to | |
Text concatenation | & | Concatenation |
Logical | && | And |
|| | or |
Relationship
With the help of DAX relationships between tables can be built to perform cohesive calculations. Relationships between tables are established using unique key identifiers that are common across tables. This enables the model to aggregate and analyze data cohesively.
Store details
Sales details
Now, herein, the product ID is the unique identifier which is common between both the tables. Now, using this relationship between the two tables, we can assess the number of units sold by product ID 10008.
References
- Anand, R. (2023). Data modeling in DAX. Retrieved from https://blog.rajanand.org/data-modeling-in-dax
- Clark, S. (2020). Power BI performance best practices. Apress.
- Datacamp. (2023). Power BI DAX tutorial for beginners. Retrieved from https://www.datacamp.com/tutorial/power-bi-dax-tutorial-for-beginners
- Dendge, K. (2021). Power BI data modeling with DAX. Medium. Retrieved from https://medium.com/@kanchandendge/power-bi-data-modeling-with-dax-747ac444b37a
- Microsoft. (2023). DAX overview. Retrieved from https://learn.microsoft.com/en-us/dax/dax-overview
- Mitchell Pearson, et al. (2020). The definitive guide to DAX: Business intelligence for Microsoft Power BI, SQL Server Analysis Services, and Excel (2nd ed.). Microsoft Press.
- Muhammad Yasir, M., et al. (2023). Flavonoids as potential DAX1 inhibitors against Ewing Sarcoma: A pharmacoinformatic and dynamic simulation study. Bioorganic Chemistry, 131, 106121.
- Naneva, S., & Stefanova, K. (2022). Enhancing interactive reporting in Power BI using DAX and M formula language. Journal of Business Analytics, 7(3), 215-228.
- Neri, E., & García-Magariño, I. (2020). Modeling and simulation of financial time series using DAX in Power BI. Computational Economics, 56(4), 951-970.
- Riedstra, T., & Tzagarakis-Foster, C. (2021). Epigenetic regulation of DAX-1 in adrenal hypoplasia congenita and dosage-sensitive sex reversal. Journal of Endocrinology, 249(2), 73-88.
- Shayan, S. (2023). Effort Audit Analytics: Understanding and improving data utilization. Springer.
- Tutorialspoint. (2023). Data modeling with DAX. Retrieved from https://www.tutorialspoint.com/data_modeling_with_dax/index.htm
- Withum. (2023). Unlocking the power of DAX in Power BI for data modeling. Retrieved from https://www.withum.com/resources/unlocking-the-power-of-dax-in-power-bi-for-data-modeling/
I work as an editor and writer for Project Guru. I have a keen interest in new and upcoming learning and teaching methods. I have worked on numerous scholarly projects in the fields of management, marketing and humanities in the last 10 years. Currently, I am working in the footsteps of the National Education Policy of India to help and support fellow professors to emphasise interdisciplinary research and curriculum design.
I am a Senior Analyst at Project Guru, a research and analytics firm based in Gurugram since 2012. I hold a master’s degree in economics from Amity University (2019). Over 4 years, I have worked on worked on various research projects using a range of research tools like SPSS, STATA, VOSViewer, Python, EVIEWS, and NVIVO. My core strength lies in data analysis related to Economics, Accounting, and Financial Management fields.
Discuss