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
Anonymous
Not applicable

Allocating contract amount over multiple years

Hello,

I have an interesting question -

Working with contracts that are generally 1 year but sometimes they go multiple years.

Each contract has a contract id, start date, end date, and amount.

I need to show contract expenditure by year.  Straight forward when contract is for one year i.e. Jan 1, 2022 thru Dec 31, 2022.

How do i allocate the amount by year if a contract starts on Feb 1, 2021 and ends on Jan 31, 2024. 

Many Thanks!

Pav 

1 ACCEPTED SOLUTION
v-xiaosun-msft
Community Support
Community Support

Hi @Anonymous ,

 

According to your description, I made a sample, and here is my solution.

Data sample:

vxiaosunmsft_0-1665127615235.png

Create a measure to calculate the total days between “start date” and “end date”.

 

Total days =
DATEDIFF ( MAX ( 'Tabelle1'[start date] ), MAX ( 'Tabelle1'[end date] ), DAY ) + 1

 

Create three measures to calculate days of every year.

 

2022 =
DATEDIFF ( MAX ( 'Tabelle1'[start date] ), DATE ( 2022, 12, 31 ), DAY ) + 1
2023 =
IF (
    MAX ( 'Tabelle1'[end date] ) > DATE ( 2022, 12, 31 ),
    DATEDIFF ( MAX ( 'Tabelle1'[start date] ), DATE ( 2023, 12, 31 ), DAY ) + 1 - 'Tabelle1'[2022]
)
2024 =
IF (
    MAX ( 'Tabelle1'[end date] ) > DATE ( 2023, 12, 31 ),
    DATEDIFF ( MAX ( 'Tabelle1'[start date] ), MAX ( 'Tabelle1'[end date] ), DAY ) + 1 - 'Tabelle1'[2022] - 'Tabelle1'[2023]
)

 

Create three measures to calculate the amount of each year.

 

amount of 2022 =
DIVIDE ( MAX ( 'Tabelle1'[amount] ), 'Tabelle1'[Total days] ) * 'Tabelle1'[2022]
amount of 2023 =
DIVIDE ( MAX ( 'Tabelle1'[amount] ), 'Tabelle1'[Total days] ) * 'Tabelle1'[2023]
amount of 2024 =
DIVIDE ( MAX ( 'Tabelle1'[amount] ), 'Tabelle1'[Total days] ) * 'Tabelle1'[2024]

 

Final output:

vxiaosunmsft_1-1665127748064.png

 

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ xiaosun

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

4 REPLIES 4
v-xiaosun-msft
Community Support
Community Support

Hi @Anonymous ,

 

According to your description, I made a sample, and here is my solution.

Data sample:

vxiaosunmsft_0-1665127615235.png

Create a measure to calculate the total days between “start date” and “end date”.

 

Total days =
DATEDIFF ( MAX ( 'Tabelle1'[start date] ), MAX ( 'Tabelle1'[end date] ), DAY ) + 1

 

Create three measures to calculate days of every year.

 

2022 =
DATEDIFF ( MAX ( 'Tabelle1'[start date] ), DATE ( 2022, 12, 31 ), DAY ) + 1
2023 =
IF (
    MAX ( 'Tabelle1'[end date] ) > DATE ( 2022, 12, 31 ),
    DATEDIFF ( MAX ( 'Tabelle1'[start date] ), DATE ( 2023, 12, 31 ), DAY ) + 1 - 'Tabelle1'[2022]
)
2024 =
IF (
    MAX ( 'Tabelle1'[end date] ) > DATE ( 2023, 12, 31 ),
    DATEDIFF ( MAX ( 'Tabelle1'[start date] ), MAX ( 'Tabelle1'[end date] ), DAY ) + 1 - 'Tabelle1'[2022] - 'Tabelle1'[2023]
)

 

Create three measures to calculate the amount of each year.

 

amount of 2022 =
DIVIDE ( MAX ( 'Tabelle1'[amount] ), 'Tabelle1'[Total days] ) * 'Tabelle1'[2022]
amount of 2023 =
DIVIDE ( MAX ( 'Tabelle1'[amount] ), 'Tabelle1'[Total days] ) * 'Tabelle1'[2023]
amount of 2024 =
DIVIDE ( MAX ( 'Tabelle1'[amount] ), 'Tabelle1'[Total days] ) * 'Tabelle1'[2024]

 

Final output:

vxiaosunmsft_1-1665127748064.png

 

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ xiaosun

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

Anonymous
Not applicable

Thank You!

I really appreciate it.

Pavan

amitchandak
Super User
Super User
Anonymous
Not applicable

Thank You!

I really appreciate it.

Pavan

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.