Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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 Name | Budget Index | Hours Budgeted | Hours worked to date | Billed hours | Unbilled hours | Amount to bill |
| Café Project 2024 | 1 | 100 | 230 | 100 | 130 | 0 |
| Café Project 2024 | 2 | 100 | 230 | 100 | 130 | 100 |
| Café Project 2024 | 3 | 100 | 230 | 100 | 130 | 30 |
| Café Project 2024 | 4 | 100 | 230 | 100 | 130 | 0 |
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.
Solved! Go to Solution.
@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
Hi,
I think this is a good use case for visual calculations. E.g.
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!
Proud to be a Super User!
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:
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.
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:
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.
Hi,
I think this is a good use case for visual calculations. E.g.
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!
Proud to be a 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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 14 | |
| 7 | |
| 4 | |
| 4 | |
| 3 |
| User | Count |
|---|---|
| 23 | |
| 10 | |
| 10 | |
| 6 | |
| 5 |