Menu
CoddyTech

Variables with VAR

Part of the DAX with CALCULATE section of Coddy's Power BI journey. Lesson 18 of 24.

VAR Name = expression names a step; RETURN gives the result.

Margin % =
VAR Cost = SUMX(Sales, Sales[Quantity] * RELATED(Products[UnitCost]))
VAR Profit = [Revenue] - Cost
RETURN DIVIDE(Profit, [Revenue])

Each variable is worked out once, under the measure's filters, and can use the ones above it.

challenge icon

Challenge

Write Margin % with variables: a Cost variable (quantity times the product's unit cost, line by line), a Profit variable (Revenue minus Cost), then return Profit divided by Revenue. It is checked for each category.

bugsy Main icon

Start this challenge with Coddy's AI tutor

What is Bugsy?

All lessons in DAX with CALCULATE