3 Dax
3 Dax
DAX
Introduction
In your experience with Power BI, you've learned to turn data into insights. In this exercise,
you’ll use DAX to calculate annual and quarterly profits and analyze data sets to create a
clear financial story.
• Create time-based summaries for displaying quarterly, annual, and year-to-date profit
data.
• Determine median sales volume to assess Tailwind Traders' performance stability.
• Utilize the Performance Analyzer tool to enhance report generation and ensure fast
loading times.
Case study
Tailwind Traders needs to generate insights into its financial performance to inform its
strategic decisions for the upcoming business year. The insights it requires include time-
based summaries that display quarterly and annual profits and year-to-date breakdowns. The
company also requires its median sales volume to assess its financial performance. Let’s help
Tailwind Traders create this report.
Instructions
Locate and open the Tailwind Traders Report.pbix Power BI file you created in the
previous exercise. If you followed the steps from the previous exercise correctly, then your
data model should resemble the one displayed in the screenshot below. Follow the prompts to
configure aggregations for this data model using DAX.
Step 1: Calculate Yearly Profit margin
2. In the formula bar, create a new column that represents the yearly profit margin. This
margin should be derived by dividing the gross revenue by the total net revenue within the
Sales in USD table.
1. Right-click on the Sales in USD table in the Fields pane and choose New Measure.
2. Create a new measure for quarterly profit. Consider using a function that aggregates data
until the end of the current quarter. To achieve this, you must reference the calculated yearly
profit and a calendar table.
Tip: Consider leveraging the DATESQTD function in DAX to break down yearly data into
quarterly segments.
1. Right-click on the Sales in USD table in the Fields pane and select New Measure.
2. Create a new measure for the year-to-date profit. You'll need a function that aggregates
data from the start of the year up to the current date.
2. In the formula bar, create a new measure to represent the median sales. Consider the
statistical functions in DAX that can help you find the middle value of gross revenue.
Hint: The median separates the higher and lower half of a data sample. MEDIAN is a DAX
function that can help you derive this directly from your sales data.
1. Find and select the Performance Analyzer option within the View tab.
2. Create an empty Card visual and drag the Yearly Profit Margin field to the Fields well.
Repeat this process for the Median Sales, Quarterly Profit, and YTD Profit.
3. Begin recording the performance of the card visuals using the Performance Analyzer’s
recording feature.
5. Observe the list of all visual items in your report and their respective load times. Ensure
the DAX query time of visual items is < 200ms and note any slow-loading visuals.
6. Select Stop and remove all Card visuals, resulting in a blank Canvas.
Conclusion
You've helped influence Tailwind Traders' strategic decisions by calculating profits and
assessing sales consistency. In the data world, accuracy and speed are key. You’ve also
demonstrated the ability to configure calculations using DAX.