Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi All,
I have calculated two measures gross margin and profit margin as above.
I have a dimension in my data set "actual" and "plan". I am able to place the actual and plan in the column but i am unsure of how to put a variance (actual - plan) into the column beside "plan". Is there a way to do this?
Thanks for your help
Solved! Go to Solution.
Hi @Anonymous ,
You need to create 3 measures as below:
Gross Margin = CALCULATE(MIN('Table'[Value]),ALLEXCEPT('Table','Table'[Category]))
Profit = CALCULATE(MAX('Table'[Value]),ALLEXCEPT('Table','Table'[Category]))
result =
VAR actual =
CALCULATE (
SWITCH (
SELECTEDVALUE ( 'Table (2)'[row] ),
"Gross Margin", 'Table'[Gross Margin],
"Profit", 'Table'[Profit]
),
'Table'[Category] = "actual"
)
VAR plan =
CALCULATE (
SWITCH (
SELECTEDVALUE ( 'Table (2)'[row] ),
"Gross Margin", 'Table'[Gross Margin],
"Profit", 'Table'[Profit]
),
'Table'[Category] = "plan"
)
RETURN
SWITCH (
SELECTEDVALUE ( 'Column'[Column] ),
"actual", actual,
"plan", plan,
plan - actual
)
and another 2 tables showed as below:
Table Column
Table Table(2)
Finally you will see:
For the related .pbix file,pls click here.
Best Regards,
Kelly
So gross profit is calculated as profit/revenue and gross margin is cost/revenue. The version is a column in my dataset containing "actual" and "plan".
Hi @Anonymous ,
You need to create 3 measures as below:
Gross Margin = CALCULATE(MIN('Table'[Value]),ALLEXCEPT('Table','Table'[Category]))
Profit = CALCULATE(MAX('Table'[Value]),ALLEXCEPT('Table','Table'[Category]))
result =
VAR actual =
CALCULATE (
SWITCH (
SELECTEDVALUE ( 'Table (2)'[row] ),
"Gross Margin", 'Table'[Gross Margin],
"Profit", 'Table'[Profit]
),
'Table'[Category] = "actual"
)
VAR plan =
CALCULATE (
SWITCH (
SELECTEDVALUE ( 'Table (2)'[row] ),
"Gross Margin", 'Table'[Gross Margin],
"Profit", 'Table'[Profit]
),
'Table'[Category] = "plan"
)
RETURN
SWITCH (
SELECTEDVALUE ( 'Column'[Column] ),
"actual", actual,
"plan", plan,
plan - actual
)
and another 2 tables showed as below:
Table Column
Table Table(2)
Finally you will see:
For the related .pbix file,pls click here.
Best Regards,
Kelly
This one is tricky. Create a diff column. for these you need to use actual and plan as filter.
The using summarize and union , you have to merge the current result with new columns.
Hi @Anonymous
You can create a measure Variance = [actual] - [plan]