Dear Excel-goeroes,
For my work I need to know how many contractual funding is available in a certain period in time. Funding covers a certain period between 2 dates, and the selected period covers a period between 2 dates as well.
I've visualized an example of this in below screenshot. With this I've visualized the fundingperiod and selectedperiod overlap with a timeline. Timeline is just to make you understand the relation, not for final formula, as I only need results as marked in green cells. Original workbook attached to this post.
![PDC_07 Oct. 30 15.52.jpg PDC_07 Oct. 30 15.52.jpg](https://chandoo.org/forum/data/attachments/1/1284-3057ac6ad9524e0b0403c10509f4f3ab.jpg)
For this I've build quite a large and complex formula, of which I think there should be an easier way and shorter formula. The formula calculates the "amount of months within a period overlap", which is enough for me to calculate the funds per month. Besides that, the current formula doesn't show correct result, when funding period overlaps selected period.
Current formula in English (translated):
Current formula in Dutch (original)
I hope someone can give me a fresh start why this goes wrong, and how I could fix this. But maybe there's a way in which this can be done with an easier formula.
Sidenote: I don't prefer to use VBA as this isn't supported in our company...
Thanks for your interest and valuable braintime...
Best regards,
Stensol, The Netherlands
For my work I need to know how many contractual funding is available in a certain period in time. Funding covers a certain period between 2 dates, and the selected period covers a period between 2 dates as well.
I've visualized an example of this in below screenshot. With this I've visualized the fundingperiod and selectedperiod overlap with a timeline. Timeline is just to make you understand the relation, not for final formula, as I only need results as marked in green cells. Original workbook attached to this post.
- In the examples my core fundingperiod (blue cells) covers 3 months (91 days exactly) with a total fund of € 9.000,-.
- But I only want to know the available funds in a selected period (red cells)
- Examples A,B,C,E have different selected periods, with each different outcomes and available funds for that period.
- all four examples have correct outcome
- Example D and F is where my formula results in wrong outcome
- ex.D should be 1 month
- ex.F should be 6 months
- Examples A,B,C,E have different selected periods, with each different outcomes and available funds for that period.
![PDC_07 Oct. 30 15.52.jpg PDC_07 Oct. 30 15.52.jpg](https://chandoo.org/forum/data/attachments/1/1284-3057ac6ad9524e0b0403c10509f4f3ab.jpg)
For this I've build quite a large and complex formula, of which I think there should be an easier way and shorter formula. The formula calculates the "amount of months within a period overlap", which is enough for me to calculate the funds per month. Besides that, the current formula doesn't show correct result, when funding period overlaps selected period.
Current formula in English (translated):
Code:
=IF(IF(AND($C2>=$C3;$D2<=$D3);(IFERROR(DATEDIF($C2;$D2;"m")+1;0));(IF(SUM(IFERROR(DATEDIF($C2;$D3;"m")+1;0))-(IFERROR(DATEDIF($C3;$D3;"m")+1;0))<=0;(IFERROR(DATEDIF($C2;$D3;"m")+1;0));(SUM(IFERROR(DATEDIF($C2;$D2;"m")+1;0))-(SUM(IFERROR(DATEDIF($C2;$D3;"m")+1;0))-(IFERROR(DATEDIF($C3;$D3;"m")+1;0)))))))<=0;0;IF(AND($C2>=$C3;$D2<=$D3);(IFERROR(DATEDIF($C2;$D2;"m")+1;0));(IF(SUM(IFERROR(DATEDIF($C2;$D3;"m")+1;0))-(IFERROR(DATEDIF($C3;$D3;"m")+1;0))<=0;(IFERROR(DATEDIF($C2;$D3;"m")+1;0));(SUM(IFERROR(DATEDIF($C2;$D2;"m")+1;0))-(SUM(IFERROR(DATEDIF($C2;$D3;"m")+1;0))-(IFERROR(DATEDIF($C3;$D3;"m")+1;0))))))))
Current formula in Dutch (original)
Code:
=ALS(ALS(EN($C2>=$C3;$D2<=$D3);(ALS.FOUT(DATUMVERSCHIL($C2;$D2;"m")+1;0));(ALS(SOM(ALS.FOUT(DATUMVERSCHIL($C2;$D3;"m")+1;0))-(ALS.FOUT(DATUMVERSCHIL($C3;$D3;"m")+1;0))<=0;(ALS.FOUT(DATUMVERSCHIL($C2;$D3;"m")+1;0));(SOM(ALS.FOUT(DATUMVERSCHIL($C2;$D2;"m")+1;0))-(SOM(ALS.FOUT(DATUMVERSCHIL($C2;$D3;"m")+1;0))-(ALS.FOUT(DATUMVERSCHIL($C3;$D3;"m")+1;0)))))))<=0;0;ALS(EN($C2>=$C3;$D2<=$D3);(ALS.FOUT(DATUMVERSCHIL($C2;$D2;"m")+1;0));(ALS(SOM(ALS.FOUT(DATUMVERSCHIL($C2;$D3;"m")+1;0))-(ALS.FOUT(DATUMVERSCHIL($C3;$D3;"m")+1;0))<=0;(ALS.FOUT(DATUMVERSCHIL($C2;$D3;"m")+1;0));(SOM(ALS.FOUT(DATUMVERSCHIL($C2;$D2;"m")+1;0))-(SOM(ALS.FOUT(DATUMVERSCHIL($C2;$D3;"m")+1;0))-(ALS.FOUT(DATUMVERSCHIL($C3;$D3;"m")+1;0))))))))
I hope someone can give me a fresh start why this goes wrong, and how I could fix this. But maybe there's a way in which this can be done with an easier formula.
Sidenote: I don't prefer to use VBA as this isn't supported in our company...
Thanks for your interest and valuable braintime...
Best regards,
Stensol, The Netherlands