Extremely Challenging Problem

spm2116

New Member
Joined
Nov 20, 2014
Messages
4
So, I've come across the most difficult Excel problem I have ever seen. I'll let you be the judge. Please chime in, as I am really stuck.

Essentially, I am trying to pull cost data (see Sheet B).

Sheet A:
A -Unique IdentifiersB -Admit Date (l)C -Discharge Date (l)D - Cost
11234567891/2/001/2/00$100
21234567891/2/001/15/00$100,000
31234567892/1/002/1/0$100
49876543211/1/001/1/00$100

<tbody>
</tbody>

Sheet B:
A -Unique IdentifiersB - Admit Date (s)C -Discharge Date (s)D -Cost
11234567891/1/001/14/00=
29876543211/30/002/3/00=

<tbody>
</tbody>

So, I am looking for the cost (Sheet B, D:D). For any date that falls between the dates in Sheet B as those dates fall between the dates in Sheet A, I want that cost summed. In the example for 123456789, I want all of the costs that appear in Sheet A for the period of 1/1/00-1/14/00. So, the answer I would want in this example is $100,100. For my purposes, it is fine that Sheet B ends on 1/14/00 and Sheet A ends on 1/15/00, so long as I am pulling in All of the $100,000 (and the $100 from 1/2/00). The amount in B3 would need to be left out of the sum because it falls outside of the range in Sheet B.

I have a few thousand lines of data, so I can't do this by hand.

My initial thought was to do a SUMPRODUCT (nested in an IF statement) for a range lookup, but then I did not know how to pull in the costs. So then I tried an IFSUMS but I couldn't really make that work.

I'm using Excel 2010 (I think, or whatever the latest one is).

PLEASE HELP!!!!!
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
SUMIFS should work. Try:

Code:
=SUMIFS('Sheet A'!D:D,'Sheet A'!A:A,'Sheet B'!A2,'Sheet A'!B:B,">="&'Sheet B'!B2,'Sheet A'!B:B,">="&'Sheet B'!B2)
 
Upvote 0
Hi Danerida,

This is very close. It pulls all of the cost from the Admit date and beyond, which would include data that is there after the discharge date. So from my above example, this formula will pull in the $100 from 2/1/00, which I would not want since that amount is outside of the window of the dates in SheetB. I'm not sure how to add that part in. I tried to add some more variables to the end, but it isn't working.


SUMIFS should work. Try:

Code:
=SUMIFS('Sheet A'!D:D,'Sheet A'!A:A,'Sheet B'!A2,'Sheet A'!B:B,">="&'Sheet B'!B2,'Sheet A'!B:B,">="&'Sheet B'!B2)
 
Last edited:
Upvote 0
Assuming both of your sheets have header's in line 1, in sheet2 cell D2 try:

Code:
=SUMPRODUCT(--(Sheet1!$A$2:$A$5=Sheet2!A2),--(Sheet1!$B$2:$B$5>=Sheet2!B2),--(Sheet1!$C$2:$C$5<=Sheet2!C2),Sheet1!$D$2:$D$5)

and drag down...
 
Last edited:
Upvote 0
This was what I had originally tried, but Excel will not let me make the unique identifiers equal one another. Also, I'm assuming by Sheet1 you mean SheetB.

Hi Danerida,

This is very close. It pulls all of the cost from the Admit date and beyond, which would include data that is there after the discharge date. So from my above example, this formula will pull in the $100 from 2/1/00, which I would not want since that amount is outside of the window of the dates in SheetB. I'm not sure how to add that part in. I tried to add some more variables to the end, but it isn't working.
 
Upvote 0
Yes, that is what I meant. But it still does not work. I was thinking of adding to the ifsums the discharge dates.It is the long way around but since the Admit dates worked, why not the discharge dates.



No, sheet1 =your sheetA, sheet2 =your SheetB
 
Upvote 0
I'm not the most experienced but it sounds like you could try powerpivot and create a relationship between the two tables?
 
Upvote 0

Forum statistics

Threads
1,216,085
Messages
6,128,732
Members
449,465
Latest member
TAKLAM

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