0
0
Power BIbi_tool~10 mins

Variables (VAR/RETURN) in Power BI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a variable named TotalSales that sums the Sales column.

Power BI
VAR TotalSales = SUM(Sales[[1]]) RETURN TotalSales
Drag options to blanks, or click blank then click option'
AAmount
BSales
CQuantity
DPrice
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong column name inside SUM.
Forgetting to use VAR before the variable name.
2fill in blank
medium

Complete the code to calculate the average price using a variable and return it.

Power BI
VAR AvgPrice = AVERAGE(Products[[1]]) RETURN AvgPrice
Drag options to blanks, or click blank then click option'
ACost
BQuantity
CPrice
DDiscount
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column that does not contain prices.
Not using RETURN to output the variable.
3fill in blank
hard

Fix the error in the code by completing the variable declaration correctly.

Power BI
VAR TotalQuantity = SUM(Sales[[1]]) RETURN TotalQuantity
Drag options to blanks, or click blank then click option'
ACustomer
BPrice
CDate
DQuantity
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-numeric column inside SUM.
Misspelling the column name.
4fill in blank
hard

Fill both blanks to calculate profit as the difference between total sales and total cost.

Power BI
VAR TotalSales = SUM(Sales[[1]]) VAR TotalCost = SUM(Sales[[2]]) RETURN TotalSales - TotalCost
Drag options to blanks, or click blank then click option'
ASales
BCost
CQuantity
DPrice
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up sales and cost columns.
Using the wrong column names.
5fill in blank
hard

Fill both blanks to calculate the profit margin percentage.

Power BI
VAR TotalSales = SUM(Sales[[1]]) VAR TotalCost = SUM(Sales[[2]]) VAR ProfitMargin = DIVIDE(TotalSales - TotalCost, TotalSales, 0) RETURN ProfitMargin
Drag options to blanks, or click blank then click option'
ASales
BCost
CQuantity
DPrice
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up sales and cost columns.
Not using DIVIDE and risking division by zero errors.