How much total sales did we make, and what was the average sales amount per order last month?
SUM and AVERAGE functions in Power BI - Dashboard Guide
| Order ID | Sales Amount | Order Date |
|---|---|---|
| 1001 | 150 | 2024-05-01 |
| 1002 | 200 | 2024-05-03 |
| 1003 | 350 | 2024-05-10 |
| 1004 | 400 | 2024-05-15 |
| 1005 | 300 | 2024-05-20 |
| 1006 | 100 | 2024-05-25 |
| 1007 | 250 | 2024-05-28 |
- KPI Card: Total Sales
Formula:Total Sales = SUM('Sales'[Sales Amount])
Result: 1750 - KPI Card: Average Sales per Order
Formula:Average Sales = AVERAGE('Sales'[Sales Amount])
Result: 250 - Bar Chart: Sales Amount by Order ID
Shows each order's sales amount as a bar for easy comparison. - Table: Detailed Sales Data
Shows all orders with their sales amounts and dates.
+----------------------+-----------------------+ | Total Sales (KPI) | Average Sales (KPI) | | [1750] | [250] | +----------------------+-----------------------+ | | | Bar Chart: Sales by Order ID | | | +----------------------------------------------+ | Table: Detailed Sales Data | +----------------------------------------------+
A date slicer can be added to filter orders by date. When the user selects a date range, the Total Sales and Average Sales KPIs update to reflect only the orders in that range. The bar chart and table also update to show only filtered orders.
If you add a filter to show only orders after 2024-05-15, which components update and what are their new values?
- Updated Total Sales: SUM of sales amounts for orders 1005, 1006, 1007 = 300 + 100 + 250 = 650
- Updated Average Sales: AVERAGE of those orders = 650 / 3 = 216.67
- Bar Chart and Table: Show only orders 1005, 1006, 1007
Practice
What does the SUM function do in Power BI?
Solution
Step 1: Identify the purpose of SUM
The SUM function adds all numeric values in a specified column, unlike AVERAGE (mean), COUNT (rows), or MAX (highest).Final Answer:
Adds all numbers in a column -> Option AQuick Check:
SUM = total addition [OK]
- Confusing SUM with AVERAGE
- Thinking SUM counts rows
- Mixing SUM with MAX or MIN
Which of the following is the correct syntax to calculate the average of the Sales[Amount] column in DAX?
?Solution
Step 1: Recall correct DAX average syntax
In DAX, use AVERAGE(Sales[Amount]); AVG() and MEAN() do not exist, while SUM/COUNT works but is indirect.Final Answer:
AVERAGE(Sales[Amount]) -> Option BQuick Check:
AVERAGE() is the direct DAX function [OK]
- Using AVG() which is not a DAX function
- Trying MEAN() which doesn't exist in DAX
- Dividing SUM by COUNT manually instead of AVERAGE
Given the table Sales with Amount values: 100, 200, 300, what is the result of this DAX measure?
TotalAmount = SUM(Sales[Amount])
AverageAmount = AVERAGE(Sales[Amount])What are the values of TotalAmount and AverageAmount?
Solution
Step 1: Compute SUM and AVERAGE values
SUM(100 + 200 + 300) = 600; AVERAGE = 600 / 3 = 200.Final Answer:
TotalAmount = 600, AverageAmount = 200 -> Option AQuick Check:
SUM = 600, AVERAGE = 200 [OK]
- Mixing sum and average values
- Dividing sum by wrong count
- Confusing average with max or min
Identify the error in this DAX formula intended to calculate the average sales amount:
AverageSales = SUM(Sales[Amount]) / COUNT(Sales)Solution
Step 1: Locate COUNT syntax error
COUNT(Sales) is invalid as COUNT requires a column like Sales[Amount], not a table.Final Answer:
COUNT(Sales) should be COUNT(Sales[Amount]) -> Option DQuick Check:
COUNT needs a column, not a table [OK]
- Using COUNT with a table instead of a column
- Assuming SUM/COUNT division is invalid
- Replacing SUM with AVERAGE without reason
You have a Sales table with columns Region and Amount. You want to create a measure that shows the average sales amount only for the "East" region. Which DAX formula correctly calculates this?
?Solution
Step 1: Construct correct filtered average DAX
Use CALCULATE(AVERAGE(Sales[Amount]), Sales[Region] = "East") to apply filter context; others invalid (no WHERE, AVERAGE can't take table from FILTER directly, COUNT misused).Final Answer:
AverageEastSales = CALCULATE(AVERAGE(Sales[Amount]), Sales[Region] = "East") -> Option CQuick Check:
CALCULATE + filter = correct average [OK]
- Using WHERE clause which is invalid in DAX
- Trying to filter inside AVERAGE directly
- Dividing SUM by COUNT with filter incorrectly
Ready to prove it?
Pass the test and this pattern moves unknown
