Hello,
I have built a spreadsheet to handle my finances (formulas only, no VBA), and now I am stuck with a formula that I thought would work... but just doesn't. Any help to fix my formula would be greatly appreciated
In my spreadsheet I have:
- the 'Expenses' table with "Account from" and "Account to" dates for each row
- my 'Summary' worksheet in which I have a "StartDate" and "EndDate" which define the period for which I want to know my expenses (for exemple if I want to know what were my expenses in August 2018, I will input "StartDate=01/08/2018" and "EndDate=31/08/2018").
In my 'Summary' worksheet, I want to sum certain types of expenses "within" the defined period - by "within" I mean that if only a portion of the expense Account dates fits into the defined period, then I will want to sum only that portion (linearly).
So I came up with the below formula, and for some reason I get a #VALUE ! error
Here are the things that I have alreay tried / done:
- I have made the calculation of the "portion" of the expense within the defined period (second line of my formula) within the Expenses table itself, and used a SUMIF in my 'Summary' sheet on the already calculated values... and it works well (so I believe I am calculating the right numbers, it is only an issue of Excel syntax). But this is just a quick fix, it's not good enough because I want to have several summarizing sheets with different dates in each sheet (for example one sheet will show the expenses per month), and I do not like the idea of bringing all the different dates into my Expenses table
- I have tried to replace all the MIN/MAX formulas with simple calculation using MIN(A,B)=(A+B-|A-B|)/2 and MAX(A,B)=(A+B+|A-B|)/2, but it didn't help
- I assumed the problem was that I was mixing arrays with numbers in the MIN / MAX formulas, so I tried to generate arrays with the StartDate / EndDate value repeated... didn't help neither
Any idea of what's wrong with my formula and how to fix it?
Many thanks for your help!
Cheers,
Larry
I have built a spreadsheet to handle my finances (formulas only, no VBA), and now I am stuck with a formula that I thought would work... but just doesn't. Any help to fix my formula would be greatly appreciated
In my spreadsheet I have:
- the 'Expenses' table with "Account from" and "Account to" dates for each row
- my 'Summary' worksheet in which I have a "StartDate" and "EndDate" which define the period for which I want to know my expenses (for exemple if I want to know what were my expenses in August 2018, I will input "StartDate=01/08/2018" and "EndDate=31/08/2018").
In my 'Summary' worksheet, I want to sum certain types of expenses "within" the defined period - by "within" I mean that if only a portion of the expense Account dates fits into the defined period, then I will want to sum only that portion (linearly).
So I came up with the below formula, and for some reason I get a #VALUE ! error
Code:
[COLOR=#333333]=SUMPRODUCT(Expenses[Amount]*(Expenses[Expense Type]=$B25),
[/COLOR][COLOR=#333333]MAX( MIN(Expenses[Account To],EndDate) - MAX(Expenses[Account From],StartDate) +1 , 0 ) / (Expenses[Account To]-Expenses[Account From]+1))[/COLOR]
Here are the things that I have alreay tried / done:
- I have made the calculation of the "portion" of the expense within the defined period (second line of my formula) within the Expenses table itself, and used a SUMIF in my 'Summary' sheet on the already calculated values... and it works well (so I believe I am calculating the right numbers, it is only an issue of Excel syntax). But this is just a quick fix, it's not good enough because I want to have several summarizing sheets with different dates in each sheet (for example one sheet will show the expenses per month), and I do not like the idea of bringing all the different dates into my Expenses table
- I have tried to replace all the MIN/MAX formulas with simple calculation using MIN(A,B)=(A+B-|A-B|)/2 and MAX(A,B)=(A+B+|A-B|)/2, but it didn't help
- I assumed the problem was that I was mixing arrays with numbers in the MIN / MAX formulas, so I tried to generate arrays with the StartDate / EndDate value repeated... didn't help neither
Any idea of what's wrong with my formula and how to fix it?
Many thanks for your help!
Cheers,
Larry