A variable names a value inside a measure. Write VAR Name = expression lines, then RETURN the result:
Margin % =
VAR Revenue = [Total Sales]
VAR Cost = [Total Cost]
RETURN DIVIDE(Revenue - Cost, Revenue)
Variables make long measures readable, and each one is computed once, which is faster than repeating the same expression.
The important rule: a variable is evaluated where it's defined, in the filter context of that moment. If you change the context later with CALCULATE, the variable keeps its value. That's useful when you want "this row's total" inside a FILTER, and a trap when you expect it to change.
Variable names can't contain spaces and shouldn't match a table name such as Sales. Press Shift+Enter in the formula bar to start a new line.