Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
bruosori
New Member

How to Calculate headcount difference between Actual and Budget

Hi,

I have the following table below:

 

DateTypeHeadcount
31/01/2022Budget3
31/01/2022Actual2
28/02/2022Budget5
28/02/2022Actual7

 

How can I create a column name "Deviation" that shows the difference between actual and budget?

Expected:

JanFeb
ActualBudgetDeviationActualBudgetDeviation
23-157-2

 

I am trying the calcuate function to create a measure however the deviation field appears duplicated for each type (Actual/Budget) 

 

Deviation:=CALCULATE(Sum[Headcount];[Type]="Actual")-CALCULATE(Sum[Headcount];[Type]="Budget")

 

Result:

JanFeb
ActualDeviationBudgetDeviationActualDeviationBudgetDeviation
2-13-15-27-2
6 REPLIES 6
tamerj1
Super User
Super User

Hi @bruosori 
Two ways of doing that https://www.dropbox.com/t/n6fnM12rCaJWnQLd

First method using a matri visul with single measure

Count = 
VAR NormalCount = 
    SUM ( 'Table'[Headcount] )
VAR BudgetCount =
    CALCULATE ( 
        SUM ( 'Table'[Headcount] ),
        'Table'[Type] = "Budget"
    )
VAR ActualCount =
    CALCULATE ( 
        SUM ( 'Table'[Headcount] ),
        'Table'[Type] = "Actual"
    )
VAR DeviationCount =
    ActualCount - BudgetCount
RETURN
    IF (
        HASONEVALUE ( 'Table'[Type] ),
        NormalCount,
        DeviationCount
    )

2nd method using a table visual and 3 mesures

Actual = 
CALCULATE ( 
    SUM ( 'Table'[Headcount] ),
    'Table'[Type] = "Actual"
)
Budget = 
CALCULATE ( 
    SUM ( 'Table'[Headcount] ),
    'Table'[Type] = "Budget"
)
Deviation = [Actual] - [Budget]

1.png

Anonymous
Not applicable

Hi, I think you mean difference instead of deviation. Try to make a calculated column "month" and create a table with this measure

Anonymous
Not applicable

Difference = 

var actual = CALCULATE(SUM(Table[Headcount]), Table[Type] = "Actual")
var budget = CALCULATE(SUM(Table[Headcount]), Table[Type] = "Budget")

return actual - budget
dhruvinushah
Responsive Resident
Responsive Resident

Hi @bruosori , 

try creating a measure for your Deviation Calculation as follows: 

Deviation = SUMX('yourTableName', [Actual] - [Budget])

Use that Deviation field in your table or matrix in Power BI. 











I don't have the columns Actual and Budget. See my table structure.

Hi @bruosori 

I would create 3 measures: 

//Measure 1
Actuals = CALCULATE(SUM(TestTable[Headcount]), TestTable[Type] = "Actual")

//Measure 2
Budgets = CALCULATE(SUM('TestTable'[Headcount]),'TestTable'[Type] = "Budget")

//Measure 3
Deviations = [Actuals] - [Budgets]

 

Once you have created these 3 measures, convert the "Date" column into a Date datatype from Text. 
You can then put the measures in a table as follows: 

dhruvinushah_0-1651874087332.png

 









Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.