DAX question on calculating difference between two column values

cr731

Well-known Member
Joined
Sep 17, 2010
Messages
611
I have a table showing a summary of values with a column for date, row type (Actuals or Budget), and the value.

I arrange this in (Power) pivot table where my Type and Date columns are in the columns, and then values are obviously in the values section. The result, for a given month, is that it shows me Actuals and Budget side-by-side.

I want to add a third column for variance between Actuals and Budget. So I tried using calculate,

=CALCULATE(SUM[Values],[Type] = "Actual")-CALCULATE(SUM[Values],[Type] = "Budget")

But the result of this is 4 columns because it repeats the variance calculation for each of the Actuals and Budget values which are in the column labels.

What's the proper way to create a calculated field to calculate the difference between two values within a single column?

It's almost like I want to mimic having row in my source table where the value in the Type column is Actuals vs. Budget, but PowerPivot, you cannot do this.

Thanks
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
I think you will have to go ahead and make the 3 measures, [Total Actual], [Total Budget] and [Actual to Budget Delta], and not have Type on columns.
 
Upvote 0
Alternatively, you can play with Named Sets under PivotTable Options, Fields, Items & Sets, and Create Set based on Rows or Columns, where the Delta is not split by Type.
But I think Scott's solution is probably cleaner.
 
Upvote 0
Another alternative would be to use the OLAP PivotTable extensions add-in to create a custom MDX query but, to echo Ozeroth, Scott's solution is standard practice and the best solution by a mile.
 
Upvote 0

Forum statistics

Threads
1,224,136
Messages
6,176,564
Members
452,735
Latest member
CristianCaruceriu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top