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

View all the Fabric Data Days sessions on demand. View schedule

Reply
jonbox
Helper II
Helper II

Measure to compared expected with actual

Hi,

 

I'm trying to create a measure to count the number of projects that went over their EXPECTED TOTAL SPEND by doing the following

 

Taking Expected total spend (this stays the same regardless of the month e.g. upgrade project in the below table isn't 8000, it's 2000 but the data just shows it at 2000 per month). Compare the sum of total spend over all months of the project, e.g. upgrade total spend is 300 + 600 + 400 + 800 = 2100 which is OVER the expected total spend of 2000.

 

Is there a measure that allows me to do this for each project? so that i can count the number over expected spend and number below?

 

ProjectNameExpected TOTAL SpendMonthTotal Spent
Upgrade20001300
Upgrade20002600
Upgrade20003400
Upgrade20004800
Expansion15001700
Expansion15002700
Expansion1500350
Refresh300011000
Refresh300022500
1 ACCEPTED SOLUTION

Num overbudget = 
var summaryTable = ADDCOLUMNS( SUMMARIZE( 
   FILTER( 'Actual Spend + Firm',  'Actual Spend + Firm'[ProjectStatus] = "Closed"),
   'Actual Spend + Firm'[ProjectName]), "@val", [Spend difference]
)
return COUNTROWS( FILTER( summaryTable, [@val] < 0) )

I think that'll do it

View solution in original post

5 REPLIES 5
johnt75
Super User
Super User

If you create a measure to calculate the difference, like

Spend difference =
var expectedSpend = MAX('Table'[Expected total spend])
var totalSpent = SUM('Table'[Total Spent])
return expectedSpend - totalSpent

then you could create a couple of measures to show the number over and under budget, e.g.

Num overbudget =
var summaryTable = ADDCOLUMNS( SUMMARIZE( 'Table'[Project]), "@val", [Spend difference])
return COUNTROWS( FILTER( summaryTable, [@val] < 0) )

Hi Johnt,

 

Do you know how i can resolve the below error? 

Num overbudget = 
var summaryTable = ADDCOLUMNS( SUMMARIZE( 'Actual Spend + Firm' [ProjectName]), "@val", [Spend difference])
return COUNTROWS( FILTER( summaryTable, [@val] < 0) )

 

jonbox_0-1648199706767.png

 

My mistake, forgot to include the table as the first parameter to SUMMARIZE

Num overbudget = 
var summaryTable = ADDCOLUMNS( SUMMARIZE( 'Actual Spend + Firm',  'Actual Spend + Firm'[ProjectName]), "@val", [Spend difference])
return COUNTROWS( FILTER( summaryTable, [@val] < 0) )

No worries, worked it out in the end. thanks a lot for the help.

 

one final thing i'm trying to add is a fitler to only perform this calculation If the project status = closed:

 

Num underbudget =
var summaryTable = ADDCOLUMNS(SUMMARIZE(FILTER('Actual Spend + Firm', 'Actual Spend + Firm'[ProjectStatus] = "Closed"( 'Actual Spend + Firm','Actual Spend + Firm'[ProjectName]), "@val", [Spend difference])
return COUNTROWS( FILTER( summaryTable, [@val] >= 0) )
 
Something like this...

Num overbudget = 
var summaryTable = ADDCOLUMNS( SUMMARIZE( 
   FILTER( 'Actual Spend + Firm',  'Actual Spend + Firm'[ProjectStatus] = "Closed"),
   'Actual Spend + Firm'[ProjectName]), "@val", [Spend difference]
)
return COUNTROWS( FILTER( summaryTable, [@val] < 0) )

I think that'll do it

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors