Forum Discussion
Calculate monthly variance
Hi everyone
Fairly new here to BI and am grappling with a suitable way to calculate the difference between Actual costs versus Budget costs on a monthly basis.
Ideally I would like to have a DAX measure that can pull together the total Actual costs and then seperately Budget costs incurred during successive months.
A simplified version of my data set is below:
| Cost Centre | Allocation | Costs | Month |
| Cost centre 1 | Actual | $ 100 | Jan-19 |
| Cost centre 2 | Actual | $ 350 | Jan-19 |
| Cost centre 3 | Actual | $ 2,500 | Jan-19 |
| Cost centre 1 | Budget | $ 80 | Jan-19 |
| Cost centre 2 | Budget | $ 400 | Jan-19 |
| Cost centre 3 | Budget | $ 2,600 | Jan-19 |
| Cost centre 1 | Actual | $ 95 | Feb-19 |
| Cost centre 2 | Actual | $ 420 | Feb-19 |
| Cost centre 3 | Actual | $ 3,000 | Feb-19 |
| Cost centre 1 | Budget | $ 80 | Feb-19 |
| Cost centre 2 | Budget | $ 400 | Feb-19 |
| Cost centre 3 | Budget | $ 2,600 | Feb-19 |
| Cost centre 1 | Actual | $ 110 | Mar-19 |
| Cost centre 2 | Actual | $ 380 | Mar-19 |
| Cost centre 3 | Actual | $ 2,400 | Mar-19 |
| Cost centre 1 | Budget | $ 80 | Mar-19 |
| Cost centre 2 | Budget | $ 400 | Mar-19 |
| Cost centre 3 | Budget | $ 2,600 | Mar-19 |
I'm struggling to pull out the Actual costs and separate from the Budget costs but I'm trying to achieve a result that would look something like this:
| Actual | $ 2,950 | Jan-19 |
| Budget | $ 3,080 | Jan-19 |
| Actual | $ 3,515 | Feb-19 |
| Budget | $ 3,080 | Feb-19 |
| Actual | $ 2,890 | Mar-19 |
| Budget | $ 3,080 | Mar-19 |
Appreciate any thoughts or suggestions.
And with a filter it looks like this:
6 Replies
- Nathaniel_C
Community Champion
Marcus_E
Try this:
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
NathanielActual costs = var _actual = CALCULATE(SUM('Table'[Costs]),ALLEXCEPT('Table','Table'[Cost Centre],'Table'[Month]),'Table'[Allocation]= "Actual") return _actual Budget Costs = var _actual = CALCULATE(SUM('Table'[Costs]),ALLEXCEPT('Table','Table'[Cost Centre],'Table'[Month]),'Table'[Allocation]= "Budget") return _actuaL- Nathaniel_C
Community Champion
And with a filter it looks like this:
- Marcus_E
Helper I
Many thanks for the prompt solution(s). They work perfectly for what I'm trying to achieve.
- Ashish_Mathur
Super User