Allocating cost based on balance on PO line

fayo2009

New Member
Joined
Apr 10, 2017
Messages
30
Office Version
  1. 365
Platform
  1. Windows
Good morning

I am looking for a formula that I can incorporate into an xlookup that will allocate the invoice value up to the value on the first PO line 1 before it uses the value in PO line 2. the xlookup is currently set to select the latest PO line number.



Invoice lineNet amount
12320,000.00
124506.50
125243.42
126189.77
127435.54
1285,000.00
12955.71
130350.28
13122,000.00
1326.34
1330.05
134411.35
135174.05
136605.78
1371,063.53
13855.69
139200.54
1400.68
14176.91
PO NumberPO LinePO Value
345678150,000.00
3456782600,000.00
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I am afraid that your question does not make sense to me (and I am guessing others, as well).

It may be helpful if you actually walk us through your example, and explain the logic as you work through it, and show us how to arrive at your expected result.
 
Upvote 0
Thanks Joe4 please see logic below .

Invoice lineNet amountAllocated PO NumberPO LinePO Line nopreferred PO line
12320000345678=XLOOKUP(C2,$A$26:$A$27,$B$26:$B$27,,,-1)21
124506.5345678=XLOOKUP(C3,$A$26:$A$27,$B$26:$B$27,,,-1)21
125243.42345678=XLOOKUP(C4,$A$26:$A$27,$B$26:$B$27,,,-1)21
126189.77345678=XLOOKUP(C5,$A$26:$A$27,$B$26:$B$27,,,-1)21
127435.54345678=XLOOKUP(C6,$A$26:$A$27,$B$26:$B$27,,,-1)21
1285000345678=XLOOKUP(C7,$A$26:$A$27,$B$26:$B$27,,,-1)21
12955.71345678=XLOOKUP(C8,$A$26:$A$27,$B$26:$B$27,,,-1)21
130350.28345678=XLOOKUP(C9,$A$26:$A$27,$B$26:$B$27,,,-1)21
13122000345678=XLOOKUP(C10,$A$26:$A$27,$B$26:$B$27,,,-1)21
1326.34345678=XLOOKUP(C11,$A$26:$A$27,$B$26:$B$27,,,-1)21
1330.05345678=XLOOKUP(C12,$A$26:$A$27,$B$26:$B$27,,,-1)21
134411.35345678=XLOOKUP(C13,$A$26:$A$27,$B$26:$B$27,,,-1)21
135174.05345678=XLOOKUP(C14,$A$26:$A$27,$B$26:$B$27,,,-1)21
136605.78345678=XLOOKUP(C15,$A$26:$A$27,$B$26:$B$27,,,-1)21
1371063.53345678=XLOOKUP(C16,$A$26:$A$27,$B$26:$B$27,,,-1)22
13855.69345678=XLOOKUP(C17,$A$26:$A$27,$B$26:$B$27,,,-1)22
139200.54345678=XLOOKUP(C18,$A$26:$A$27,$B$26:$B$27,,,-1)22
1400.68345678=XLOOKUP(C19,$A$26:$A$27,$B$26:$B$27,,,-1)22
14176.91345678=XLOOKUP(C20,$A$26:$A$27,$B$26:$B$27,,,-1)22
PO NumberPO LinePO Value
345678150000
3456782600000
 
Upvote 0
I am still looking for a detailed explanation.
 
Upvote 0
I am still looking for a detailed explanation.
No problem and thanks for looking into it

I used the xlookup formular to look up the PO line number based on the PO number assigned to the various invoices. The xlookup formular is set to select the last PO line. However I am looking for a formula that will select the1st PO line and allocate as much invoice line value. when there is not enough PO value on the 1st PO line it would move on and use the balance on the second PO line.
 
Upvote 0
OK, I think I see what you are trying to do now.
I am pretty sure that there are probably ways to do it with formulas, but I am having a tough time getting it to work out the way that I want, since you are really matching on two values (Number and Value). I will have to keep playing around with it. Usually, when I get stuck trying to figure out a formula, I opt for a VBA solution.
 
Upvote 0
In your actual/real data, do you have multiple different PO Numbers in the summary below to choose from?
If it is always just one, and it always matches the data in your table, it would be much easier.
I am just trying to determine if your example is realistic, or a simplified version of the actual data.
 
Upvote 0
In your actual/real data, do you have multiple different PO Numbers in the summary below to choose from?
If it is always just one, and it always matches the data in your table, it would be much easier.
I am just trying to determine if your example is realistic, or a simplified version of the actual data.
Yes in the real actual data there are multiple PO numbers and PO lines. The PO number is mapped to the invoice line based on the service type (I have already have formula for that). I am looking for a formula that will select the1st PO line and allocate as much invoice line value. when there is not enough PO value on the 1st PO line it would move on and use the balance on the second PO line.
 
Upvote 0
OK, I think I see what you are trying to do now.
I am pretty sure that there are probably ways to do it with formulas, but I am having a tough time getting it to work out the way that I want, since you are really matching on two values (Number and Value). I will have to keep playing around with it. Usually, when I get stuck trying to figure out a formula, I opt for a VBA solution.
Thanks for your help, much appreciated. I have been on it for months myself and trying to avoid VBA. the work around at the moment is to remove the additional PO lines from the table and wait until the Old one is used up.
 
Upvote 0
Try placing the following formulas in cells C2 and D2, respectively, and drag-copying them down as needed:
Excel Formula:
=INDEX($A$26:$A$27,MATCH(TRUE,$C$26:$C$27-SUMIFS($B$1:$B1,$C$1:$C1,$A$26:$A$27,$D$1:$D1,$B$26:$B$27)>=B2,0))
=INDEX($B$26:$B$27,MATCH(TRUE,$C$26:$C$27-SUMIFS($B$1:$B1,$C$1:$C1,$A$26:$A$27,$D$1:$D1,$B$26:$B$27)>=B2,0))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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