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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
TomKelly
Frequent Visitor

DAX Support on budget billing amount

Hi All,

 

I am working on a report that requires me to calculate the amount that needs to be billed for each project, specifically for each budget. However, I’m struggling to build out the calculation such that it takes into account the context of the previous budgets for each row. I’d appreciate some help with this.

 

Here is some example data:

Project NameBudget IndexHours BudgetedHours worked to dateBilled hoursUnbilled hoursAmount to bill
Café Project 202411002301001300
Café Project 20242100230100130100
Café Project 2024310023010013030
Café Project 202441002301001300

 

What I’m looking to create is the calculation for the highlighted ‘Amount to Bill’ field. This field should show exactly what amount should be billed to each budget, using what has already been billed (Billed Hours) to understand whether the budget has already been ‘used up’ and taking into consideration what the budget for that row is (Hours Budgeted), such that it doesn’t bill more than the budget for that row.

 

The tricky part I’ve struggled with is when the amount to bill runs over multiple budgets, and showing only the remaining amount for the ‘currently active’ budget – in this case, Budget 3 at 30.

 

This is what I’ve created so far, but I am not such how to consider the outcome of this calculation from the previous record.

 

 

Amount to Bill =
   VAR CurrentBudget = 'Table'[Hours Budgeted]
   VAR PreviousBilled =
   CALCULATE(
      SUM('Table'[Billed Hours]),
      FILTER(
         'Table',
         'Table'[Project Name] = EARLIER('Table'[Project Name]) &&
         'Table'[Budget Index] < EARLIER('Table'[Budget Index])
      )
   )
   VAR RemainingHours = 'Table'[Hours Worked to Date] - PreviousBilled

RETURN
   IF(RemainingHours > CurrentBudget, CurrentBudget, RemainingHours)

 

 

 I appreciate the support from this community. This is my first post, so i'm missing anything feel free to let me know and I can add it. 

3 ACCEPTED SOLUTIONS
BeaBF
Super User
Super User

@TomKelly Try with:

 

Amount to Bill =
VAR CurrentBudget = 'Table'[Hours Budgeted]
VAR CurrentWorked = 'Table'[Hours Worked to Date]
VAR PreviousBilled =
CALCULATE(
SUM('Table'[Billed Hours]),
FILTER(
'Table',
'Table'[Project Name] = EARLIER('Table'[Project Name]) &&
'Table'[Budget Index] < EARLIER('Table'[Budget Index])
)
)
VAR RemainingHours = CurrentWorked - PreviousBilled
VAR AmountToBill =
IF(RemainingHours > CurrentBudget, CurrentBudget, RemainingHours)

RETURN
MAX(0, AmountToBill)

 

BBF

View solution in original post

ValtteriN
Community Champion
Community Champion

Hi,

I think this is a good use case for visual calculations. E.g. 

Versus previous = VAR RemainingHours =  RUNNINGSUM([Hours Budgeted])
return
[Hours worked to date]-
RemainingHours


Amount to bill1 =
var _r =
PREVIOUS([Versus previous])-IF([Versus previous]<0,0,[Versus previous])
RETURN
IF(_r<0,0,_r)



By using these two here is the end result:
ValtteriN_0-1729764562814.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Anonymous
Not applicable

Hi @TomKelly 

 

Thanks for the reply from BeaBF and ValtteriN , please allow me to provide another insight:

 

Please try modifying the formula to the following:

Amount to Bill = 
   VAR CurrentBudget = 'Table'[Hours Budgeted]
   VAR PreviousBilled =
   CALCULATE(
      SUM('Table'[Billed Hours]),
      FILTER(
         'Table',
         'Table'[Project Name] = EARLIER('Table'[Project Name]) &&
         'Table'[Budget Index] < EARLIER('Table'[Budget Index])
      )
   )
   VAR RemainingHours = IF(PreviousBilled <> BLANK(), 'Table'[Hours Worked to Date] - PreviousBilled, 0)
RETURN
IF(RemainingHours <= 0, 0, IF(RemainingHours > CurrentBudget, CurrentBudget, RemainingHours))

 

Output:

vxuxinyimsft_0-1729823801514.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @TomKelly 

 

Thanks for the reply from BeaBF and ValtteriN , please allow me to provide another insight:

 

Please try modifying the formula to the following:

Amount to Bill = 
   VAR CurrentBudget = 'Table'[Hours Budgeted]
   VAR PreviousBilled =
   CALCULATE(
      SUM('Table'[Billed Hours]),
      FILTER(
         'Table',
         'Table'[Project Name] = EARLIER('Table'[Project Name]) &&
         'Table'[Budget Index] < EARLIER('Table'[Budget Index])
      )
   )
   VAR RemainingHours = IF(PreviousBilled <> BLANK(), 'Table'[Hours Worked to Date] - PreviousBilled, 0)
RETURN
IF(RemainingHours <= 0, 0, IF(RemainingHours > CurrentBudget, CurrentBudget, RemainingHours))

 

Output:

vxuxinyimsft_0-1729823801514.png

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ValtteriN
Community Champion
Community Champion

Hi,

I think this is a good use case for visual calculations. E.g. 

Versus previous = VAR RemainingHours =  RUNNINGSUM([Hours Budgeted])
return
[Hours worked to date]-
RemainingHours


Amount to bill1 =
var _r =
PREVIOUS([Versus previous])-IF([Versus previous]<0,0,[Versus previous])
RETURN
IF(_r<0,0,_r)



By using these two here is the end result:
ValtteriN_0-1729764562814.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




BeaBF
Super User
Super User

@TomKelly Try with:

 

Amount to Bill =
VAR CurrentBudget = 'Table'[Hours Budgeted]
VAR CurrentWorked = 'Table'[Hours Worked to Date]
VAR PreviousBilled =
CALCULATE(
SUM('Table'[Billed Hours]),
FILTER(
'Table',
'Table'[Project Name] = EARLIER('Table'[Project Name]) &&
'Table'[Budget Index] < EARLIER('Table'[Budget Index])
)
)
VAR RemainingHours = CurrentWorked - PreviousBilled
VAR AmountToBill =
IF(RemainingHours > CurrentBudget, CurrentBudget, RemainingHours)

RETURN
MAX(0, AmountToBill)

 

BBF

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.