Query question

dspangenberg

New Member
Joined
Sep 30, 2003
Messages
19
Hi all,

I'm having difficulties getting this query together.

I have a table cashflow containing several fields: ProjectID, Year, Cash_in Cash_out

Now if i have three records from One project eg:
projectID Year Cash_in CashOut
1 2000 200 300
1 2001 400 200
1 2002 400 400
2 2001 2000 3000
.. ...... ...... .......


Goal is to derive a Payback field that gives me the year in which the project was payedback. So in the case of ProjectID 1 it would be year 2001
payback field = sum (cash_in) >= sum(cash_out)

but if i use the sum function it will calculate every record of project_ID 1
it has to stop where the criteria is met.

any ideas?

any help is appreciated.

Sincerely Yours,

D. Spangenberg
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi D,

Can you give some more details, or rephrase. I'm not clear on the project id and how you determined 2001 was paid back?

Ziggy
 
Upvote 0
Hi Ziggy,

Code:
projectID Year Cash_in CashOut 
1          2000  200      300 
1          2001  400      200 
1          2002  400      400 
2          2001  2000    3000

So for projectID 1, the year in which it was paid back is 2001 cause:
year 2000 --> cash_in >= Cash_out = false

Code:
year 2000  --> cash_in >= Cash_out  AND
year 2001  --> cash_in >= Cash_out = true

example in numbers would be 
year  cash_in  cash_out
2000  200       300
2001  400       200

sum   600       500

so 2001 would be the first year in which the project was paid back.

Hopefully you understand what i'm trying to achieve here.


Greetings D.
 
Upvote 0

Forum statistics

Threads
1,221,621
Messages
6,160,879
Members
451,675
Latest member
Parlapalli

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top