Bird
Raised Fist0
Power BIbi_tool~8 mins

Basic arithmetic in DAX in Power BI - Dashboard Guide

Choose your learning style10 modes available
Dashboard Mode - Basic arithmetic in DAX
Business Question

How much total revenue and profit did each product generate, and what is the average profit per sale?

Sample Data
ProductUnits SoldUnit PriceUnit Cost
Notebook1053
Pen2021
Eraser1510.5
Marker831.5
Ruler1242
Dashboard Components
  • KPI Card: Total Revenue
    Formula: Total Revenue = SUMX(Sales, Sales[Units Sold] * Sales[Unit Price])
    Result: 10*5 + 20*2 + 15*1 + 8*3 + 12*4 = 50 + 40 + 15 + 24 + 48 = 177
  • KPI Card: Total Profit
    Formula: Total Profit = SUMX(Sales, Sales[Units Sold] * (Sales[Unit Price] - Sales[Unit Cost]))
    Result: (10*(5-3)) + (20*(2-1)) + (15*(1-0.5)) + (8*(3-1.5)) + (12*(4-2)) = 20 + 20 + 7.5 + 12 + 24 = 83.5
  • KPI Card: Average Profit per Sale
    Formula: Average Profit per Sale = DIVIDE([Total Profit], SUM(Sales[Units Sold]))
    Result: 83.5 / (10+20+15+8+12) = 83.5 / 65 = 1.2846
  • Table: Sales Details
    Columns: Product, Units Sold, Unit Price, Unit Cost, Revenue, Profit
    Revenue formula per row: Units Sold * Unit Price
    Profit formula per row: Units Sold * (Unit Price - Unit Cost)
Dashboard Layout
+----------------------+----------------------+----------------------+
|   Total Revenue KPI   |    Total Profit KPI  | Average Profit per   |
|                      |                      |       Sale KPI       |
+----------------------+----------------------+----------------------+
|                      Sales Details Table                      |
|                                                              |
+--------------------------------------------------------------+
Interactivity

A slicer for Product allows filtering all KPIs and the sales details table to show data only for the selected product(s). When a product is selected, the Total Revenue, Total Profit, and Average Profit per Sale update accordingly, and the table shows only rows for that product.

Self Check

If you add a filter to show only the product Pen, which components update and what are their new values?

  • Total Revenue: 20 units * $2 = $40
  • Total Profit: 20 units * ($2 - $1) = $20
  • Average Profit per Sale: $20 / 20 units = $1
  • Sales Details Table: Shows only the row for Pen with calculated Revenue $40 and Profit $20
Key Result
Dashboard showing total revenue, total profit, and average profit per sale by product with interactive filtering.

Practice

(1/5)
1. What does the DAX expression Total Sales = SUMX(Sales, Sales[Quantity] * Sales[Price]) calculate?
easy
A. The division of quantity by price
B. The sum of quantity and price
C. The difference between quantity and price
D. The total sales amount by multiplying quantity and price

Solution

  1. Step 1: Understand the multiplication operator in DAX

    The asterisk (*) symbol multiplies two numbers or columns in DAX.
  2. Step 2: Analyze the expression components

    SUMX(Sales, Sales[Quantity] * Sales[Price]) iterates over Sales table, multiplies Quantity and Price row-by-row, and sums the results.
  3. Final Answer:

    The total sales amount by multiplying quantity and price -> Option D
  4. Quick Check:

    Quantity * Price = Total Sales [OK]
Hint: Multiply quantity and price to get total sales [OK]
Common Mistakes:
  • Confusing multiplication with addition
  • Using division instead of multiplication
  • Ignoring the column context in calculation
2. Which of the following is the correct syntax to create a new measure that subtracts Discount from TotalPrice in DAX?
easy
A. NewMeasure = TotalPrice + Discount
B. NewMeasure := TotalPrice - Discount
C. NewMeasure = TotalPrice - Discount
D. NewMeasure - TotalPrice - Discount

Solution

  1. Step 1: Recall the correct assignment operator in DAX

    DAX uses the equals sign (=) to assign expressions to measures.
  2. Step 2: Check the arithmetic operator for subtraction

    The minus sign (-) subtracts one value from another.
  3. Final Answer:

    NewMeasure = TotalPrice - Discount -> Option C
  4. Quick Check:

    Use '=' for assignment and '-' for subtraction [OK]
Hint: Use '=' to assign and '-' to subtract in DAX [OK]
Common Mistakes:
  • Using ':=' instead of '=' for measure assignment
  • Using '+' instead of '-' for subtraction
  • Missing the assignment operator
3. Given the DAX measure:
Profit = SUM(Sales[Revenue]) - SUM(Sales[Cost])
and the Sales table has Revenue = 1000 and Cost = 700,
what is the value of Profit?
medium
A. 1700
B. 300
C. 700
D. 1000

Solution

  1. Step 1: Calculate the sum of Revenue

    SUM(Sales[Revenue]) = 1000 as given.
  2. Step 2: Calculate the sum of Cost and subtract

    SUM(Sales[Cost]) = 700, so Profit = 1000 - 700 = 300.
  3. Final Answer:

    300 -> Option B
  4. Quick Check:

    Revenue - Cost = 300 [OK]
Hint: Subtract total cost from total revenue to get profit [OK]
Common Mistakes:
  • Adding instead of subtracting
  • Using individual row values instead of sums
  • Confusing Revenue and Cost columns
4. Identify the error in this DAX measure:
NetAmount = SUM(Sales[Amount]) + - SUM(Sales[Discount])
medium
A. No error, the syntax is correct
B. Missing parentheses around SUM functions
C. SUM function cannot be used with columns
D. Incorrect use of '+ -' operators together

Solution

  1. Step 1: Analyze the operator usage

    The '+ -' uses unary minus after addition, which is valid in DAX.
  2. Step 2: Verify the expression

    SUM(Sales[Amount]) + (-SUM(Sales[Discount])) correctly computes net amount as Amount minus Discount.
  3. Final Answer:

    No error, the syntax is correct -> Option A
  4. Quick Check:

    SUM(Amount) + -SUM(Discount) = Net Amount [OK]
Hint: '+ -' is valid unary minus for subtraction [OK]
Common Mistakes:
  • Thinking '+ -' is invalid syntax
  • Assuming parentheses are always required around SUM
  • Thinking SUM can't be used on columns
5. You want to create a measure that calculates the average price after applying a 10% discount on the Price column. Which DAX expression correctly applies this?
hard
A. AvgDiscountedPrice = AVERAGEX(Sales, Sales[Price] * 0.9)
B. AvgDiscountedPrice = AVERAGE(Sales[Price] * 0.9)
C. AvgDiscountedPrice = SUM(Sales[Price * 0.9]) * 0.9 / COUNT(Sales[Price])
D. AvgDiscountedPrice = SUM(Sales[Price] * 0.9) / COUNT(Sales[Price])

Solution

  1. Step 1: Understand the requirement

    We need the average of prices after applying a 10% discount on each price (row context).
  2. Step 2: Analyze each option

    Averaging requires row-by-row computation for expressions: AVERAGEX(Sales, Sales[Price] * 0.9) correctly iterates and averages discounted prices. A, C, and D have syntax errors (aggregate on expression without iterator or invalid column reference).
  3. Final Answer:

    AvgDiscountedPrice = AVERAGEX(Sales, Sales[Price] * 0.9) -> Option A
  4. Quick Check:

    Use AVERAGEX for average of row expressions [OK]
Hint: Apply discount inside AVERAGEX to get correct result [OK]
Common Mistakes:
  • Using AVERAGE on expression without iterator
  • Using SUM and COUNT instead of AVERAGEX
  • Invalid column references like [Price * 0.9]
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard