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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Simsy
Frequent Visitor

Target vs Actual not working with filters :-(

Hi Guys,

I've been tasked with generating a PowerBi report that compares actual billable hours with a percentage target that needs to be calculated at different levels. I've managed to make work at a single level, but it falls apart when I add more slicers.

 

The small table below is an extract of a dataset which runs > 100,000 rows

 

The calculation I'm trying to do, is for eaxmple;

  • Steve in Month = Jan has booked (128+25+7) 160 hours in total
  • His target is to have 72% of the total be 'Billable'
  • 128/160 = 80% which is above his target

This simple calculation I can do, by using CALCULATE, SUM & ALLEXCEPT but when I want to see his performance over 2,3 or 4 months the output of my measure makes no sense, likewise if I want to see all the Plumbers in January, it gets worse still and when I add slicers to show the combined result by country/Role/Month.

 

I think my problem is, I'm trying to calculate the measure too soon . . . each measure needs to be based on the total number of hours booked by each person in each month, but when grouping people together I need to see the 'Cost Type' Hours / Sum('month' hours)

 

ANY  help would be gratefully appreciated.

Thanks

 

Country   NameRoleMonthCost TypeHours Booked% Target
England   Steve  Plumber Jan  Billable12872%
England   Steve  Plumber Jan unbillable 
2515%
England   Steve  Plumber Jan Vacation713%
England   Steve  Plumber Feb  Billable11275%
England   Steve  Plumber Feb  unbillable3515%
England   Steve  Plumber Feb  Vacation1310%
England   Steve  Plumber  March  Billable11980%
England   Steve  Plumber March  unbillable3313%
England   Steve  Plumber March  Vacation87%
England   Jane Electrician Jan  Billable13072%
England   Jane Electrician Jan  unbillable1215%
England   Jane Electrician Jan  Vacation3013%
England   Jane Electrician Feb  Billable10075%
England   Jane Electrician Feb  unbillable2315%
England   Jane Electrician Feb  Vacation2210%
England   Jane Electrician March  Billable11680%
England   Jane Electrician March  unbillable1313%
England  Jane Electrician March  Vacation367%

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Here is the pedestrian way of doing it. It requires fields to be present in the visual for the measure to work.

 

 

 

 

%Targ := 
var n=SELECTEDVALUE(Costs[   Name])
var r=SELECTEDVALUE(Costs[Role])
var m=SELECTEDVALUE(Costs[Month])
var t=CALCULATE(sum(Costs[Hours Booked]),Allselected(Costs),Costs[   Name]=n,Costs[Role]=r,Costs[Month]=m)
return divide(sum(Costs[Hours Booked]),t)

 

 

 

 

lbendlin_0-1595976309332.png

 

 

That's not optimal if you want flexibility. For that you will want to look at other options like this one which will work regardless of the other filters.

 

 

 

%Targ2 := DIVIDE(sum(Costs[Hours Booked]),CALCULATE(sum(Costs[Hours Booked]),ALL(Costs[Cost Type])))

 

 

@Greg_Deckler Can you please teach me how to write this without Calculate?

 

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Here is the pedestrian way of doing it. It requires fields to be present in the visual for the measure to work.

 

 

 

 

%Targ := 
var n=SELECTEDVALUE(Costs[   Name])
var r=SELECTEDVALUE(Costs[Role])
var m=SELECTEDVALUE(Costs[Month])
var t=CALCULATE(sum(Costs[Hours Booked]),Allselected(Costs),Costs[   Name]=n,Costs[Role]=r,Costs[Month]=m)
return divide(sum(Costs[Hours Booked]),t)

 

 

 

 

lbendlin_0-1595976309332.png

 

 

That's not optimal if you want flexibility. For that you will want to look at other options like this one which will work regardless of the other filters.

 

 

 

%Targ2 := DIVIDE(sum(Costs[Hours Booked]),CALCULATE(sum(Costs[Hours Booked]),ALL(Costs[Cost Type])))

 

 

@Greg_Deckler Can you please teach me how to write this without Calculate?

 

Many thanks lbendlin, the 2nd  solution you offered not only solved my problem, but also helped me enhance the report even more 🙂

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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