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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Kolumam
Post Prodigy
Post Prodigy

Calculating prorated value based on a condition

I have the below table.

Kolumam_0-1594304432315.png

I need to calculate the annual contract based on the start date and end date of the contract.

 

As you can see from the above table, the first contract starts at 1 July 2019 and ends at 31 Aug 2019. So the annual contract price for 2019 would be (Comprehensive Price * 60/180) where 60 is the number of days between start date of contract and end date of contract and 180 is the number of days in that year starting from July 2019.

So here is the expected output with calculation for your reference:

YearAnnual Contract Price
2019(375*60/180)+(405*120/180) = 395
2020(405*90/365)+(385*240/365) = 353.01 (approx)
2021(385*365/365) = 385

 

The above calculation applies only if we have two contracts falling on the same year with different comprehensive price. On the other hand if you have the below table where there is just one contract a year

Kolumam_1-1594305475215.png

the below should be the output:

Kolumam_2-1594305529381.png

So for 2017 here, the price is 380 since it is 380*365/365 eventhough contracts starts only from 1 April 2017 and then from 2018 onwards it is prorated. So it will be (380*90/365)+(410*240)/365

 

How do I create a DAX that satisifes both these conditions?

 

@amitchandak @parry2k @mahoney19 @Amit @amitchandak @parry2k @az38 @jdbuchanan71 @mahoneypat @edhans @harshnathani @v-kellya-msft @MFelix @Ashish_Mathur @BA_Pete @ryan_mayu @kbuckvol @Alexander76877 @Petazo @Mariusz @TomMartens @Greg_Deckler @tjd @Sean @mikstra @AllisonKennedy @EricHulshof @briandpeterson @USG_Phil @vpatel55 @mwegener @v-piga-msft @tex628 @sturlaws @Vvelarde @CheenuSing @MarcelBeug @Zubair_Muhammad @v-piga-msft @danextian @MattAL @MattAllington @roalexan @Alexander76877 @kgc 

 

1 ACCEPTED SOLUTION
tex628
Community Champion
Community Champion

Hello @Kolumam,

Take a look at the pbix attached to this reply, i hope it can provide some insight! 

Br, 
J


Connect on LinkedIn

View solution in original post

3 REPLIES 3
tex628
Community Champion
Community Champion

Hello @Kolumam,

Take a look at the pbix attached to this reply, i hope it can provide some insight! 

Br, 
J


Connect on LinkedIn
v-deddai1-msft
Community Support
Community Support

Hi @Kolumam ,

 

I spent a lot of time on this, but your logic is too complicated, I really can't write a suitable formula, I hope super user can help you well.

 

Best Regards,

Dedmon Dai

Hi @Kolumam 

 I could provide a Power Query solution for that.

If that's OK, please confirm how to handle partial end years: Shall they be considered as full years like the parital start years or taken pro rata?

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.