Main Book

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 71

www.eyowhite.

com

Copyright © 2024 Eyo Eyo

All rights reserved.

No part of this book shall be reproduced, stored in a retrieval system, or


transmitted by any means, electronic, mechanical, photocopying, recording, or
otherwise, without written permission from the publisher. No patent liability is
assumed with respect to the use of the information contained herein. Although
every precaution has been taken in the preparation of this book, the author
assumes no responsibility for errors or omissions. Nor is any liability assumed
for damages resulting from the use of the information contained herein.
POWER BI DAX FUNCTIONS

Contents
About the Author................................................................................................................................ 3
Important information ........................................................................................................................ 4
PART 1 ........................................................................................................................................... 7
Aggregate functions ........................................................................................................................... 7
SUMX Function ........................................................................................................................... 8
AVERAGE Function ..................................................................................................................... 9
AVERAGEX & AVERAGE Functions.............................................................................................. 10
AVERAGE and SUM Functions ................................................................................................... 12
VARX.P & AVERAGE Functions ................................................................................................... 14
SUM & DISTINCTCOUNT Functions............................................................................................ 17
SUM & SUMX Functions ............................................................................................................ 18
STDEV.P Function ..................................................................................................................... 20
MAX Function ........................................................................................................................... 22
MEDIAN & VAR.P Functions ....................................................................................................... 23
PART 2 ......................................................................................................................................... 25
Time Intelligence Functions.............................................................................................................. 25
CLOSINGBALANCEMONTH ....................................................................................................... 26
CLOSINGBALANCEMONTH ....................................................................................................... 27
CLOSINGBALANCEQUARTER .................................................................................................... 28
CLOSINGBALANCEQUARTER .................................................................................................... 30
CLOSINGBALANCEYEAR........................................................................................................... 33
DATEADD ................................................................................................................................. 34
DATEADD ................................................................................................................................. 35
DATESBETWEEN ....................................................................................................................... 37
DATESINPERIOD ....................................................................................................................... 38
DATESINPERIOD ....................................................................................................................... 40
DATESINPERIOD ....................................................................................................................... 42
DATESINPERIOD ....................................................................................................................... 43
DATESMTD ............................................................................................................................... 44
DATESQTD ................................................................................................................................ 45
DATESYTD ................................................................................................................................ 46
ENDOFMONTH ......................................................................................................................... 47

1|Pa ge
POWER BI DAX FUNCTIONS

ENDOFQUARTER ...................................................................................................................... 48
ENDOFYEAR ............................................................................................................................. 49
FIRSTDATE ................................................................................................................................ 50
FIRSTNONBLANK...................................................................................................................... 51
FIRSTNONBLANK...................................................................................................................... 52
LASTDATE ................................................................................................................................. 53
LASTNONBLANK ....................................................................................................................... 54
LASTNONBLANKVALUE ............................................................................................................. 55
PARALLELPERIOD ..................................................................................................................... 55
TOTALMTD ................................................................................................................................ 57
TOTALQTD ................................................................................................................................ 59
TOTALYTD ................................................................................................................................. 61
APPENDIX ....................................................................................................................................... 63

2|Pa ge
POWER BI DAX FUNCTIONS

About the Author

Dr. Eyo Eyo (PhD) is a University Lecturer and accomplished researcher in the fields of

machine learning, data analysis, and engineering.

Eyo holds a Doctor of Philosophy (PhD) degree, which stands as a testament to his dedication

to advancing knowledge in data science and engineering. His academic journey has been

marked by a relentless pursuit of excellence, resulting in numerous scholarly achievements

and contributions that have enriched his discipline.

Eyo’s commitment to education goes beyond the classroom, as he continually seeks

innovative ways to engage students and foster a deeper understanding of complex subjects.

In the realm of research, Eyo has made significant strides. His work in machine learning and

data analysis has led to groundbreaking insights and practical applications, contributing to

the advancement of knowledge through numerous published works.

As you delve into the pages of Eyo's book, “Power BI DAX Functions”, you will discover the

depth of his expertise and the invaluable insights he brings to the world of data analysis in

general.

3|Pa ge
Important information

Welcome to "POWER BI DAX FUNCTIONS" This book is designed to be your

comprehensive guide to mastering some of the functions in Power BI using practical

scenarios.

Data Analysis Expressions (DAX) is a compilation of functions and operators utilised

to construct formulas and expressions within Power BI, Analysis Services, and Power

Pivot data models in Excel.

This book covers both aggregate and time intelligence functions as types of data

analysis expressions (DAX). Whether you're a beginner looking to build a strong

foundation or an experienced practitioner aiming to sharpen your skills this book will

help you achieve your aims in data analysis and visualisations.

Power BI comprises software services, applications, and connectors that all work to

transform disparate data sources into cohesive, visually engaging, and interactive

insights.

You can use Power BI to link to your data sources, visualise key insights, and distribute

them to your desired audience in an effortless manner.

Dataset used in this book.

The database used in this book has been carefully constructed by the author to the fit

the exercises contain herein on aggregate and time intelligence functions. Access to

these databases can be acquired from this link. Scroll down the page to the Power BI

DAX Functions Database button and download the database called “Dashboard

dataset”.

4|Pa ge
Microsoft Power BI Installation

In the Appendix, you'll find comprehensive instructions for installing Power BI desktop

on Windows 10.

Who This Book Is For

This "POWER BI DAX Functions" assumes some fundamental knowledge of Power

BI at the least. Nevertheless, it is intended for a wide audience, including:

• Beginners: If you're new to Power BI, it might be best to consult some of the

textbooks and free resources you can find in the public domain to get started

on the fundamentals. Although, this book commences from basic exercises and

gradually progress to more advanced ones.

• Students and Educators: Whether you're a student studying database

management or an educator looking for resources to teach Power BI, this book

provides a rich set of exercises that can be used for learning or teaching

purposes.

• Power BI Professionals: Experienced database administrators, data

engineers, data analysts, and developers can benefit from this book by using it

as a reference and for honing their Power BI skills with challenging exercises.

5|Pa ge
Feedback

Your feedback and suggestions are greatly valued. If you have any comments,

questions, or ideas for improvement, please don't hesitate to reach out on any of the

following platforms:

• Twitter: https://twitter.com/Eyowhite3

• Website: https://eyowhite.com/contact/

Your input will help enhance future editions of this book.

Thank you for choosing " POWER BI DAX Functions " We hope this book serves as a

valuable resource in your journey to become a proficient Power BI user.

Happy visualising!

[Eyo Eyo]

6|Pa ge
PART 1
Aggregate functions

7|Pa ge
SUMX Function

1. What is the total sales amount by product and segment? Assuming the Sales
column has not been already calculated.

Explanation:
This question is relevant for understanding which products are performing well in
different market segments, allowing for targeted marketing strategies and product
development.

Syntax:

Total Sales = SUMX('Dashboard dataset', 'Dashboard


dataset'[Units Sold] * 'Dashboard dataset'[ Unit Price ])

Suggested visual:

A stacked bar chart or stacked column chart would be ideal for comparing total
sales across products and segments.

• Drag the "Product" field to the Axis area.


• Drag the "Segment" field to the Legend area.
• Drag the "Total Sales" measure you created to the Values area.

8|Pa ge
AVERAGE Function

2. What is the average unit price across different products?

Explanation:
This question can help identify pricing strategies across the product range,
offering insights into how pricing varies between products and potentially
impacting sales strategy and product development.

Syntax:

Avg unit price = AVERAGE('Dashboard dataset'[ Unit Price ])

Suggested visual:

A stacked bar chart or stacked column chart would be ideal for comparing total
sales across products and segments.

9|Pa ge
• Drag the "Product" field to the Axis area.
• Drag the " Avg unit price " measure you created to the Values area.

AVERAGEX & AVERAGE Functions

3. How does the average unit price vary across different countries, and what is the
impact of discount bands on it?

Explanation:

This question seeks to understand the pricing strategy in various markets and how
discounts affect the selling price on average. To extract this information, you can
use a combination of DAX functions to calculate the average unit price by country
and discount band.

10 | P a g e
Syntax:

Average Unit Price by Country and Discount = AVERAGEX(


SUMMARIZE(
'Dashboard dataset',
[Country],
[Discount Band],
"Avg Unit Price", AVERAGE('Dashboard dataset'[Unit Price])
),[Avg Unit Price])

Suggested visual:

A heatmap or a clustered bar chart would be effective.

For a heatmap:
Rows: Countries
Columns: Discount Bands
Colour Intensity: Average Unit Price (the higher the price, the more intense the
colour).
This visualisation allows quick identification of patterns or anomalies in pricing
strategies across different markets and how discounting affects pricing.

For a clustered bar chart:


• X-Axis: Countries
• Y-Axis: Average Unit Price
• Bars: Grouped by Discount Band within each country.

11 | P a g e
AVERAGE and SUM Functions

4. What is the profitability per unit sold for each product, and how does it vary by
market segment?"

Explanation:
This question aims to uncover the profitability of each product across different
market segments, helping to identify which products are most profitable and in
which segments they perform best. To answer this, you would calculate the profit
per unit (by subtracting the cost of goods sold (COGS) per unit from the selling
price per unit) and then aggregate this information by product and segment.

Syntax:

Profit per Unit = AVERAGE('Dashboard dataset'[Unit Price]) -


(SUM('Dashboard dataset'[COGS]) / SUM('Dashboard dataset'[Units
Sold]))

12 | P a g e
Suggested visual:

For visualising the profit per unit by product for each market segment, a treemap
or bubble chart could be particularly effective:

Treemap:

This visualisation is suitable for hierarchical data and can effectively show the
profit per unit for each product within market segments. Each segment can be a
large rectangle, with smaller rectangles inside it representing each product's
contribution to the segment's overall profitability. The size of each product
rectangle would be proportional to the profit per unit, allowing for easy
comparison across products and segments.

Bubble Chart: In a bubble chart:

• X-Axis: Market Segment


• Y-Axis: Profit per Unit
• Bubble Size: Volume of Units Sold
• Bubble Colour: Product

13 | P a g e
VARX.P & AVERAGE Functions

5. What is the variance in units sold across different products in each country?

Explanation:

This question aims to uncover the consistency (or lack thereof) in the number of
units sold for different products within each country, which can provide insights
into market demand variability and product performance stability.

Syntax:

Variance Units Sold by Product and Country = VARX.P(GROUPBY(


'Dashboard dataset',
'Dashboard dataset'[Country],
'Dashboard dataset'[Product]
),
CALCULATE(AVERAGE('Dashboard dataset'[Units Sold])))

14 | P a g e
Suggested visual:

A heatmap or a treemap could be particularly effective for visualizing this


information.

Heatmap Visualisation
• X-Axis (Columns): Products. Each column represents a different product. This
arrangement allows viewers to compare across products horizontally.
• Y-Axis (Rows): Countries. Each row represents a different country. This setup
facilitates comparison across countries vertically.
• Colour Intensity: Represents the variance in units sold. Higher variance could be
represented by a more intense or warmer colour, indicating greater fluctuation in
the number of units sold for a product in a country. Lower variance could be
represented by a cooler or less intense colour, indicating more consistency in
sales volume.
Treemap Visualisation

Treemaps don't have traditional axes like bar charts or line charts, but they do have
hierarchical structures that allow for effective data representation:
• Blocks (Rectangles): Each block represents a combination of country and
product, with the entire visualisation encompassing all such combinations.
• Block Size: Represents the variance in units sold. Larger blocks indicate a higher
variance in units sold for that product in the specified country, highlighting areas
with more significant sales fluctuations.
• Block Colour: Could also represent the variance or could be used to distinguish
between countries for easier visualisation. Similar to the heatmap, a range of
colours could indicate the level of variance, or different colours could simply
represent different countries for quick identification.

15 | P a g e
16 | P a g e
SUM & DISTINCTCOUNT Functions

6. What is the total number of units sold per segment, adjusted for the number of
distinct products sold in each segment?

Explanation:

This question aims to analyse the efficiency of sales by segment, considering the
diversity of products sold. It requires calculating the total units sold per segment
and then adjusting this figure by the number of distinct products in each segment
to understand sales performance relative to product range.

Syntax:

Adjusted Units Sold per Segment = SUM('Dashboard dataset'[Units


Sold]) / DISTINCTCOUNT('Dashboard dataset'[Product])

Suggested visual:

A bar chart would serve well to visualise this data. Each bar could represent a
different market segment, with the height of the bar indicating the adjusted total
units sold for that segment. This visualisation allows stakeholders to compare
performance across segments, considering the diversity of products sold in each
segment.

• X-Axis: Market Segments. Each category on the axis represents a different


market segment (e.g., Channel Partners, Enterprise, Midmarket, Small
Business).
• Y-Axis: Adjusted Units Sold. This axis quantifies the average or adjusted
number of units sold per distinct product in each segment, providing a

17 | P a g e
comparative measure of sales efficiency or effectiveness across
segments.

SUM & SUMX Functions

7. Which product has the highest sales to manufacturing cost ratio across all market
segments?

Explanation:

This question aims to identify the most cost-efficient products in terms of the ratio
of sales to manufacturing costs. Understanding this ratio can help highlight which
products offer the best return on the cost of production, a key metric for guiding
production and marketing strategies.

18 | P a g e
Syntax:

Sales to Manufacturing Cost Ratio = SUM('Dashboard


dataset'[Sales ]) / SUMX('Dashboard dataset', 'Dashboard
dataset'[Units Sold] * 'Dashboard dataset'[Manufacturing Price])

Suggested visual:

A bar chart would be effective for visualising this measure:

• X-Axis: Products. This axis lists all the products present in the dataset,
allowing for a direct comparison of their performance in terms of the sales
to manufacturing cost ratio.
• Y-Axis: Sales to Manufacturing Cost Ratio. The calculated measure would
be plotted on this axis, showcasing the efficiency of each product in
generating sales relative to its manufacturing costs.
• Colour or Details: Could be used to differentiate market segments if the
analysis needs to drill down further, offering insights into which segments
these efficient products perform best in.

19 | P a g e
STDEV.P Function

8. What is the standard deviation of sales across different segments to identify


volatility in sales performance?

20 | P a g e
Explanation:

This question seeks to understand the variability or consistency of sales within


each market segment. A high standard deviation indicates greater volatility,
suggesting that sales performance is less predictable and more variable. In
contrast, a low standard deviation suggests more stable sales performance within
that segment.
Syntax:

Segment Sales StdDev = CALCULATE(STDEV.P('Dashboard


dataset'[Sales ]), ALLEXCEPT('Dashboard dataset', 'Dashboard
dataset'[Segment]))

Suggested visual:

Bar Chart:
• X-Axis: Market Segments (from 'Dashboard dataset'[Segment]).
• Y-Axis: Segment Sales StdDev (the standard deviation of sales).

21 | P a g e
MAX Function

9. What are the maximum sales achieved by any single transaction across each
product category?

Explanation:

This question aims to identify the peak sales performance for individual
transactions within each product category, providing insights into the potential
sales ceiling and highlighting best-case scenarios. Understanding the maximum
sales achieved can help in setting benchmarks and expectations for sales
strategies.

Syntax:

Max Sales by Product Category = CALCULATE(MAX('Dashboard


dataset'[Sales ]), ALLEXCEPT('Dashboard dataset', 'Dashboard
dataset'[Product]))

Suggested visual:

A column chart would be well-suited for visualising the maximum sales achieved
by product category:

• X-Axis: Product Categories. This axis lists the different product categories
available in the dataset, allowing for an easy comparison across
categories.
• Y-Axis: Max Sales by Product Category. This axis shows the maximum sales
value achieved in each category, highlighting the peak performance.
• Colour Coding or Details: Additional details could include the product
name or transaction date for the maximum sales transaction, providing

22 | P a g e
deeper insights into when and with which products these peaks were
achieved.

MEDIAN & VAR.P Functions

10. Analyse Performance by segments with Median and Variance of Unit Sales
Which segments exhibit the highest median unit sales while maintaining low
variance, indicating consistent performance?

Syntax:

Median Units Sold by Segment = CALCULATE(MEDIAN('Dashboard


dataset'[Units Sold]), ALLEXCEPT('Dashboard dataset',
'Dashboard dataset'[Segment]))

23 | P a g e
Variance Units Sold by Segment = CALCULATE(VAR.P('Dashboard
dataset'[Units Sold]),ALLEXCEPT('Dashboard dataset', 'Dashboard
dataset'[Segment]))

Suggested visual:

Create a scatter plot with "Country" on the X-axis and "Median Units Sold" on the
Y-axis.
Add another Y-axis and plot "Unit Sales Variance" on it.
Use bubble size to represent the total number of units sold in each country.
This visualisation helps identify regions with both high median sales and low
variance, representing consistently strong performance.

Alternative Visualisation:

Create a bubble chart with "Median Units Sold" on the X-axis and "Unit Sales
Variance" on the Y-axis.
Use bubble size to represent the total number of units sold in each country.
This helps visualise the concentration of countries based on median sales and
variance, highlighting outliers with either very high or very low variances.

24 | P a g e
PART 2
Time Intelligence Functions

25 | P a g e
CLOSINGBALANCEMONTH

1. What is the monthly trend of closing sales balance for a specific product
segment?

Syntax:

Closing Sales Balance 2010 = CALCULATE (CLOSINGBALANCEMONTH (


SUM ('Dashboard dataset'[ Sales ]),'Dashboard dataset'[Order
Date]),
YEAR ('Dashboard dataset'[Order Date]) = 2010)

Explanation:

This measure will give you the cumulative sales balance for each month.

Suggested visual:

Create a Line Chart Visualisation: Insert a line chart visualisation onto your Power
BI report canvas.

• Configure Visual: Drag the 'Order Date' field to the x-axis of the line chart
and drag the 'Closing Sales Balance' measure to the values section of the
line chart.

• Filter by Product Segment (Optional): If you want to analyse the sales trend
for a specific product segment, you can add a filter to the visual by dragging
the 'Segment' field to the visual's filter pane and selecting the desired
segment.

26 | P a g e
CLOSINGBALANCEMONTH

2. Analysing the Cumulative Profit Margin for a specific product segment.

Syntax:

Cumulative Profit Margin 2010 = CALCULATE (CLOSINGBALANCEMONTH


(SUM ('Dashboard dataset'[ Sales ]) - SUM('Dashboard dataset'[
COGS ]),'Dashboard dataset'[Order Date]),
YEAR ('Dashboard dataset'[Order Date]) = 2010)

Explanation:

This measure calculates the month-end inventory levels.

Suggested visual:

Create a Line Chart Visualisation: Insert a line chart visualisation onto your Power
BI report canvas.

27 | P a g e
• Configure Visual: Drag the 'Order Date' field to the x-axis of the line chart
and drag the 'Month-end Inventory' measure to the values section of the
line chart.

• Filter by Product Segment (Optional): If you want to analyse the inventory


levels for a specific product segment, you can add a filter to the visual by
dragging the 'Segment' field to the visual's filter pane and selecting the
desired segment.

CLOSINGBALANCEQUARTER

3. What is the trend of cumulative sales revenue by quarter for a specific product
segment?

Syntax:

Cumulative Sales Revenue by Quarter = CLOSINGBALANCEQUARTER (SUM


('Dashboard dataset'[ Sales ]), 'Dashboard dataset'[Order
Date],FILTER ('Dashboard dataset', YEAR ('Dashboard
dataset'[Order Date]) = 2012))

28 | P a g e
Explanation:

This measure will give you the cumulative sales revenue for each quarter of the
year 2012.

Suggested visual:

Create a Line Chart Visualisation: Insert a line chart visualisation onto your Power
BI report canvas.

• Configure Visual: Drag the 'Order Date' field to the x-axis of the line chart
and drag the 'Cumulative Sales Revenue by Quarter' measure to the values
section of the line chart.

• Add Filters for Product Segment (Optional): If you want to analyse the trend
for a specific product segment, you can add a filter to the visual by dragging
the 'Segment' field to the visual's filter pane and selecting the desired
segment.

29 | P a g e
CLOSINGBALANCEQUARTER
4. What is the trend of cumulative units sold by quarter for a specific product?

Syntax:

Cumulative Units Sold by Quarter = CLOSINGBALANCEQUARTER (SUM


('Dashboard dataset'[Units Sold]), 'Dashboard dataset'[Order
Date])

30 | P a g e
Explanation:

This measure will give you the cumulative units sold for each quarter.

Suggested visual:

Create a Line Chart Visualisation: Insert a line chart visualisation onto your Power
BI report canvas.

• Configure Visual: Drag the 'Order Date' field to the x-axis of the line chart
and drag the 'Cumulative Units Sold by Quarter' measure to the values
section of the line chart.
• Add Filters for Product (Optional): If you want to analyse the trend for a
specific product, you can add a filter to the visual by dragging the 'Product'
field to the visual's filter pane and selecting the desired product.

31 | P a g e
32 | P a g e
CLOSINGBALANCEYEAR

5. What is the trend of cumulative sales revenue over the year 2011 for a specific
product segment?

Syntax:

Cumulative Sales Revenue 2011 = CALCULATE (CLOSINGBALANCEYEAR (


SUM ('Dashboard dataset'[ Sales ]),'Dashboard dataset'[Order
Date]),YEAR ('Dashboard dataset'[Order Date]) = 2011)

Explanation:

This measure will give you the cumulative sales revenue for each month in the year
2011.

Suggested visual:

Create a Card Visualisation.

• Insert a Card chart visualisation onto your Power BI report canvas.

• Configure Visual: Drag the 'Cumulative Sales Revenue 2011' measure to


the values section of the Card chart.

33 | P a g e
DATEADD

6. What was the sales growth rate for each product category in the year 2010?

Syntax:

Yearly Sales Growth Rate 2010 = VAR CurrentYearSales =


CALCULATE(SUM('Dashboard dataset'[ Sales ]), 'Dashboard
dataset'[Order Date].[Year] = 2010) VAR PreviousYearSales =
CALCULATE(SUM('Dashboard dataset'[ Sales ]),
DATEADD('Dashboard dataset'[Order Date], -1, YEAR), 'Dashboard
dataset'[Order Date].[Year] = 2009)
RETURN
IF(ISBLANK(PreviousYearSales), BLANK(), (CurrentYearSales -
PreviousYearSales) / PreviousYearSales)

Suggested visual:

Create a New Table Visualisation.

• Go to the "Report" view, and under "Visualisations", select "Table". Drag


and drop the following fields into the table:

• Product Yearly Sales Growth Rate 2009


• Visualise the Data: Displaying the year-over-year sales growth rate for each
product category in 2009 in a table allows for easy comparison. You can
also add conditional formatting to highlight positive and negative growth
rates for better visualisation.

34 | P a g e
DATEADD

7. How has the sales performance changed year-over-year for each product
segment?

Syntax:

YoY Sales = CALCULATE(SUM('Dashboard dataset'[ Sales ]),


DATEADD('Dashboard dataset'[Order Date], -1, YEAR)) -
SUM('Dashboard dataset'[ Sales ])

Explanation:

This measure calculates the difference in total sales amount between the current
period and the same period in the previous year directly using the "Order Date"
field.

35 | P a g e
Suggested visual:

A line chart or bar chart can effectively represent these changes over time.

• For a line chart:


Drag the "Order Date" field to the Axis area, the "YoY Sales" measure to the
Values area, and the "Segment" field to the Legend area if you wish to
compare different segments.
• For a bar chart: You can use a similar setup to compare different periods
directly.

36 | P a g e
DATESBETWEEN

8. What were the total sales during June 2009 promotional period for each product?

Syntax:

Sales During Promotion = CALCULATE(SUM('Dashboard dataset'[


Sales ]), DATESBETWEEN('Dashboard dataset'[Order Date], "2009-
06-01", "2009-06-30"))

37 | P a g e
DATESINPERIOD

9. What was the total sales growth over the 6 months leading up to the end of 2011
for each product category?
Syntax:

Sales 6 Months to End of 2011 = CALCULATE(SUM('Dashboard


dataset'[ Sales ]),DATESINPERIOD('Dashboard dataset'[Order
Date], DATE(2011,12,31), -6, MONTH))

Explanation:
This measure calculates the total sales from July 1, 2011, to December 31, 2011,
for each product category.

38 | P a g e
Suggested visual:

Select a visualisation type that clearly presents the historical sales data for
comparison across product categories.

• Bar Chart: Drag the "Product" field to the Axis area and the "Sales 6 Months
to End of 2011" measure to the Values area to compare sales across
different product categories during the second half of 2011.

• Line Chart: If your dataset has sufficient date granularity, use the "Order
Date" on the Axis, aggregated by month, with the "Product" field as a
Legend to display how sales trends developed over those 6 months.

39 | P a g e
DATESINPERIOD

10. Track monthly sales volume over the past year for each country.
Syntax:

Sales Volume 2011 = CALCULATE(SUM('Dashboard dataset'[Units


Sold]), DATESINPERIOD('Dashboard dataset'[Order Date],
DATE(2011, 12, 31), // End of the target year -1, YEAR //
Looking back 1 year from the specified end date))

40 | P a g e
Explanation:

This measure computes the total units sold (or total sales) for each country, from
the end of the last complete month going back 12 months.

Suggested visual:

A line chart or a stacked column chart can effectively display the monthly sales
volume trend for each country.

• Line Chart: Use the "Order Date" field grouped by month on the Axis, the
"Monthly Sales Volume" measure in the Values, and the "Country" field in
the Legend. This setup will illustrate how sales volumes have trended over
the last year across different countries.

• Stacked Column Chart: Similar setup as the line chart but provides a visual
segmentation of sales volume by country each month, making it easier to
compare the relative contributions of different countries to total sales.

41 | P a g e
DATESINPERIOD

11. Track the decline or growth in sales during the last quarter of 2010 fiscal
year compared to the same quarter in the previous fiscal year.

Syntax:

YoY Q4 Sales Change between '09 & '10 = CALCULATE(SUM('Dashboard


dataset'[ Sales ]),DATESINPERIOD('Dashboard dataset'[Order
Date],DATE(2010, 12, 31), // End of Q4 in the current fiscal
year -3, MONTH // Last quarter duration)) -
CALCULATE(SUM('Dashboard dataset'[ Sales ]),DATESINPERIOD(
'Dashboard dataset'[Order Date],DATE(2009, 12, 31), // End of
Q4 in the previous fiscal year-3, MONTH))

42 | P a g e
Explanation:

This measure computes the difference in sales revenue between the two quarters,
indicating whether there's been growth or decline.

Suggested visual:

A card visualisation can effectively display the net change in sales, making it clear
whether sales have increased or decreased.

Card Visualisation: Drag the "YoY Q4 Sales Change" measure into a card to
present the result as a single, impactful number. This visualisation quickly
communicates the performance without needing to interpret complex charts.

DATESINPERIOD

12. Calculate the average monthly sales volume for ‘Paseo’ product over the
past 6 months to inform inventory and production planning.

Syntax:

Avg Monthly Paseo Sales Volume = CALCULATE(AVERAGE('Dashboard


dataset'[Units Sold]),DATESINPERIOD('Dashboard dataset'[Order
Date],LASTDATE(ALL('Dashboard dataset'[Order Date])), //
Ensures it captures the last date in your dataset-6, MONTH),
'Dashboard dataset'[Product] = "Paseo")

43 | P a g e
Explanation:

This measure calculates the average of 'Units Sold' for "Product A" over the last 6
months from the last available date in your data. Adjust the product filter as
necessary for your specific analysis.

Suggested visual:
A Card Visualisation is ideal for displaying the average monthly sales volume,
providing a clear and concise metric that can be quickly understood.
To add this measure to your dashboard, simply drag the "Avg Monthly Sales
Volume" measure into a new card visualisation on your report canvas.

DATESMTD

13. What is the total sales amount month-to-date?

Syntax:

MTD Sales = CALCULATE(SUM('Dashboard dataset'[


Sales ]),DATESMTD('Dashboard dataset'[Order Date]))

Explanation:

This measure dynamically calculates the total sales from the beginning of the
current month to the current date, providing an up-to-date view of sales
performance.

44 | P a g e
Suggested visual:

A Card Visualisation is an effective way to display the MTD sales figure. It provides
a clear and concise presentation of the total sales amount for the current month,
making it easy for decision-makers to quickly assess sales performance.
To add this measure to your report, drag the "MTD Sales" measure into a card
visualization on your report canvas.

DATESQTD

14. What is the total sales revenue quarter-to-date?

Syntax:

QTD Sales Revenue = CALCULATE(SUM('Dashboard dataset'[


Sales ]), // Assuming 'Sales' represents the revenue
DATESQTD('Dashboard dataset'[Order Date]))

Explanation:

This measure dynamically computes the total sales revenue from the beginning of
the current quarter to today, providing an up-to-date snapshot of sales
performance.

45 | P a g e
Suggested visual:

A Card Visualisation is highly effective for presenting this single measure. It


provides a clear and concise display of the QTD sales revenue, making it
straightforward for decision-makers to assess the company's current financial
performance.
To add this measure to your report, simply drag the "QTD Sales Revenue" measure
into a card visualization on your report canvas.

DATESYTD

15. What is the total sales revenue year-to-date (YTD)?

Syntax:

YTD Sales Revenue = CALCULATE(SUM('Dashboard dataset'[


Sales ]), DATESYTD('Dashboard dataset'[Order Date]))

Explanation:

This DAX formula dynamically calculates the total sales revenue from January 1st
of the current year to the current date, providing an up-to-date snapshot of the
sales performance.

46 | P a g e
Suggested visual:

Card Visualisation:

Drag the "YTD Sales Revenue" measure into a card visualisation on your report
canvas. This visualisation type is ideal for displaying a single, impactful metric like
YTD sales revenue, offering a clear and immediate view of the company's financial
performance.

ENDOFMONTH

16. What is the sales revenue on the last day of the most recent complete
month?

Syntax:

Last Day Sales = CALCULATE(SUM('Dashboard dataset'[ Sales ]),


ENDOFMONTH('Dashboard dataset'[Order Date]))

Explanation:

This formula calculates the sales revenue for the last day of the month, based on
the most recent month's data available in your dataset.

47 | P a g e
Suggested visual:

A card visualisation is the most straightforward way to display this single measure.
It provides an immediate view of the sales revenue achieved on the last day of the
most recent complete month, offering a clear snapshot of month-end sales
performance.
Drag the "Last Day Sales" measure into a card visualisation on your report canvas.

ENDOFQUARTER

17. What is the total sales revenue on the last day of the most recent complete
quarter?

Syntax:

Last Quarter Day Sales = CALCULATE(SUM('Dashboard dataset'[


Sales ]), ENDOFQUARTER('Dashboard dataset'[Order Date]))

Explanation:

This measure calculates the sales revenue for the final day of the last complete
quarter, providing a precise snapshot of quarterly sales closure.

48 | P a g e
Suggested visual:

A card visualisation is highly effective for presenting this single measure. It offers
a clear and immediate display of the sales revenue on the last day of the most
recent quarter, serving as a crucial metric for quarterly performance reviews.
To add this measure to your report, simply drag the "Last Quarter Day Sales"
measure into a card visualization on your report canvas.

ENDOFYEAR

18. What was the total sales revenue on the last day of the previous fiscal year?

Syntax:

Last Day Previous Year Sales = CALCULATE(SUM('Dashboard


dataset'[ Sales ]),ENDOFYEAR(DATEADD('Dashboard dataset'[Order
Date], -1, YEAR)))

Explanation:

This measure dynamically calculates the total sales revenue for the last day of the
previous fiscal year, providing insight into the year-end sales performance.

49 | P a g e
Suggested visual:

A card visualisation is ideal for presenting this single measure. It offers a clear and
direct view of the sales revenue on the last day of the previous fiscal year, making
it easy for stakeholders to gauge financial performance at a crucial reporting
milestone.
Drag the "Last Day Previous Fiscal Year Sales" measure into a card visualisation
on your report canvas.

FIRSTDATE

19. What was the sales revenue on the first day of sales for ‘Amarilla’ launch?

Syntax:

First Day Sales for Amarilla = VAR FirstSaleDate = CALCULATE(


FIRSTDATE('Dashboard dataset'[Order Date]),'Dashboard
dataset'[Product] = "Amarilla",ALL('Dashboard dataset'))
RETURN
CALCULATE(SUM('Dashboard dataset'[ Sales ]),'Dashboard
dataset'[Order Date] = FirstSaleDate,'Dashboard
dataset'[Product] = "Amarilla")

50 | P a g e
Suggested visual:

Use a Card Visualisation to display the measure "First Day Sales Product A". This
effectively presents the sales revenue on the first sale date for the product.
Drag the newly created measure into a card visualisation on your Power BI report
canvas.

FIRSTNONBLANK

20. What is the first product sold at the beginning of the year 2012?

Syntax:

First Product Sold 2012 = CALCULATE(FIRSTNONBLANK('Dashboard


dataset'[Product], SUM('Dashboard dataset'[ Sales ])),FILTER(
ALL('Dashboard dataset'),'Dashboard dataset'[Order Date] >=
DATE(2012, 1, 1) &&'Dashboard dataset'[Order Date] < DATE(2013,
1, 1)))

Explanation:

This DAX formula specifically filters the data for the year 2012 and identifies the
first non-blank "Product" value that has associated sales, indicating it was the first
product sold that year.

51 | P a g e
Suggested visual:

Utilize a card visualisation to display the measure "First Product Sold 2012." This
visualisation type is highly effective for presenting a singular, impactful metric, like
identifying the first product sale of a specific year.
To add this measure to your report, drag the "First Product Sold 2012" measure
into a card visualisation on your report canvas.

FIRSTNONBLANK

21. What is the name of the first product sold this month, and what was the
value of that sale?

Syntax:

First Product Sold in 2010 = VAR FirstSaleDate2010 = CALCULATE(


MIN('Dashboard dataset'[Order Date]),FILTER(ALL('Dashboard
dataset'),YEAR('Dashboard dataset'[Order Date]) = 2010))
RETURN
CALCULATE(FIRSTNONBLANK('Dashboard dataset'[Product], 1),
'Dashboard dataset'[Order Date] = FirstSaleDate2010)

Suggested visual:

Card Visualisation: This is ideal for displaying the name of the first product sold in
2010, providing a clear and focused insight into the starting point of that year's
sales activity.

52 | P a g e
LASTDATE

22. What was the sales revenue on the last transaction date of the most
recent month in the dataset?

Syntax:

Last Day Sales Recent Month = CALCULATE(SUM('Dashboard dataset'[


Sales ]),LASTDATE('Dashboard dataset'[Order Date]))
Explanation:

This DAX formula dynamically calculates the sales revenue on the last day for
which sales were recorded in the dataset, focusing on the most recently
completed month.

Suggested visual:

A card visualisation is highly effective for displaying this single measure. It


provides a clear and immediate view of the sales revenue on the last transaction
date of the most recent month, offering a snapshot of how the month concluded
in terms of sales.
Drag the "Last Day Sales Recent Month" measure into a card visualisation on your
Power BI report canvas.

53 | P a g e
LASTNONBLANK

23. Which product was the last to be sold in the dataset?


Syntax:

Last Product Sold = LASTNONBLANK('Dashboard dataset'[Product],


CALCULATE(SUM('Dashboard dataset'[ Sales ])))

Suggested visual:

Card Visualisation is Ideal for displaying the name of the last product sold and its
sales value. However, given the complexity of showing both the product name and
its sales value in one measure, you might display the product name using this
measure and create another measure or tooltip to show the sales value.

54 | P a g e
LASTNONBLANKVALUE

24. What was the sales value of the last product sold in the dataset?

Syntax:

Last Sale Value = LASTNONBLANKVALUE('Dashboard dataset'[Order


Date], CALCULATE(SUM('Dashboard dataset'[ Sales ])))

Suggested visual:

Given that the output is a single value (the sales amount of the last product sold),
a card visualisation is most appropriate. It provides a clear and immediate display
of this key piece of information.
To implement, simply drag the "Last Sale Value" measure into a card visualisation
on your Power BI report canvas.

PARALLELPERIOD

25. How did our average unit price compare to the same period one year ago
across different product categories and countries?

55 | P a g e
Syntax:

PriceComparisonYoY = VAR PreviousY = PARALLELPERIOD('Dashboard


dataset'[Order Date], 12, MONTH)
RETURN
AVERAGEX(FILTER('Dashboard dataset',
YEAR('Dashboard dataset'[Order Date]) = 2009
),
'Dashboard dataset'[ Unit Price ]
) -
AVERAGE('Dashboard dataset'[ Unit Price ])

Suggested visual:

Choose a Stacked Bar Chart.

• Set the Axis to 'Dashboard dataset'[Products][Segment].


• Set the Legend to 'Dashboard dataset'[Dates][Country].
• Set the Values to PriceComparisonYoY.
• Filter and Analyse:

• Use the slicers and filters available in Power BI to analyse the price
comparison for specific segments, countries, or timeframes.
• Identify products or countries with significant price increases or decreases
compared to the previous year.

56 | P a g e
TOTALMTD

26. What is the total sales value month-to-date for each product category,
segmented by different sales segments, in the year 2012?

57 | P a g e
Syntax:

TotalSalesMTD_2012 = TOTALMTD(SUM('Dashboard dataset'[


Sales ]), 'Dashboard dataset'[Order Date],
FILTER(ALL('Dashboard dataset'[Order Date]), 'Dashboard
dataset'[Order Date] <= DATE(2012, 12, 31)))

Suggested visual:

Create a Visualisation: Go to the "Report" tab and choose a visualization type that
best represents the total sales value for each product category across different
sales segments. A clustered column chart or a matrix could work well for this
purpose.

Add Fields to the Visualisation: Drag the "Product" field to the axis of the
visualisation, the "Segment" field to the legend or rows section, and the
"TotalSalesMTD_2011" measure to the values section.

58 | P a g e
TOTALQTD

27. What is the total revenue quarter-to-date for each product category in the
year 2011?

Syntax:

TotalRevenueQTD_2011 = TOTALQTD(SUM('Dashboard dataset'[


Sales ]), 'Dashboard dataset'[Order Date],
FILTER(ALL('Dashboard dataset'[Order Date]), 'Dashboard
dataset'[Order Date] <= DATE(2011, 12, 31) ))

59 | P a g e
Suggested visual:

Create a Visualisation: Go to the "Report" tab and choose a visualization type that
best represents the total revenue for each product category in the year 2011. A
clustered column chart or a matrix could work well for this purpose.

Add Fields to the Visualisation: Drag the "OrderDate" field to the axis of the
visualisation and the "TotalRevenueQTD_2011" measure to the values section.

60 | P a g e
TOTALYTD

28. What is the year-to-date total sales revenue for each product category up
to the year 2012?

Syntax:

TotalSalesYTD_2012 = TOTALYTD(SUM('Dashboard dataset'[


Sales ]), 'Dashboard dataset'[Order Date], 'Dashboard
dataset'[Order Date].[Date], "12/31/2012")

Suggested visual:

Create a Visualisation: Go to the "Report" tab and choose a visualisation type that
best represents the total sales revenue for each product category up to the year
2012. A clustered column chart or a matrix could work well for this purpose.

Add Fields to the Visualisation: Drag the "Product" field to the axis of the
visualisation and the "TotalSalesYTD_2012" measure to the values section.

61 | P a g e
62 | P a g e
APPENDIX

Microsoft Power BI Installation Guide


You can follow the instructions using this link from Microsoft or follow the guide below.

Power BI Desktop is available for free download.

You can obtain Power BI Desktop through one of two methods:

1. Install it as an app from the Microsoft Store.

2. Download it directly as an executable and install it on your computer.

Both options ensure you have the latest version of Power BI Desktop on your computer.

Note:

Power BI Desktop undergoes monthly updates based on customer feedback and feature
enhancements. Support is provided exclusively for the latest version. Should you contact
Power BI Desktop Support, you'll be prompted to upgrade to the newest version.

1. Installing as an app from the Microsoft Store

You have several options for accessing the latest version of Power BI Desktop from the
Microsoft Store.

i. To access the Power BI Desktop page on the Microsoft Store, you can:
• Directly navigate to the Power BI Desktop page on the Microsoft Store using a web
browser.
• Within the Power BI service, click on the Download icon in the upper right corner,
then select Power BI Desktop.

63 | P a g e
• Visit the Power BI Desktop product page and click on "Download Free."

ii. Once you're on the Power BI Desktop page in the Microsoft Store, click on
"Install."

64 | P a g e
2. Download Power BI Desktop directly.
To obtain the Power BI Desktop executable from the Download Center, choose
"Download" on the Download Center page. Next, specify whether you want to download
the 32-bit or 64-bit installation file.

Installing Power BI Desktop after download

After completing the download, you'll be prompted to run the installation file.

Once you initiate the installation package, Power BI Desktop installs as an application
and operates on your desktop.

65 | P a g e
Launching Power BI Desktop

When you launch Power BI Desktop, a welcome screen appears as follows:

66 | P a g e
Upon first launch of Power BI Desktop, if it's not an upgrade, you'll be asked to complete
a form or sign in to the Power BI service before proceeding.

Following this, you can start crafting data models or reports and share them with others
via the Power BI service.

67 | P a g e

You might also like