Show Total Only Once for Order# with Multiple Lines

jarett

Board Regular
Joined
Apr 12, 2021
Messages
165
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have this spreadsheet that contains order lines, some orders only have one line, easy enough to display to "net invoice" total. The orders with multiple lines is where I am stuck. If the order has multiple lines, the "additional charges/deductions" are always on the first line of the order. So if an order has multiple lines I need to add the (total of column L to column M+N)-O=P, and I only want to display P on the first line of the order. Column L is a detail field and M,N,O are all header fields in the DB I am pulling from.

INVOICE 03012024.xlsx
BCDEFGHIJKLMNOP
1SalesOrderNoInvoiceDateUDF_EMPLOYEE_NAMEUDF_EXTCUSTPOUDF_EXTRAORDERINFORMATIONItemCodeItemCodeDescShipToCityShipToStateShipToZipCodeExtensionAmtFreightAmtSalesTaxAmtDepositAmtNet Invoice
284323103/1/2024 0:00AGUSTIN RODRIGUEZIKIHWYN7JGARYVILLE8051-33BKHigh Sierra Elite Fly-By 17 inWalkerLA707857811.537.76097.29
384241913/1/2024 0:00BOBBY RUMOREWDHH8M0AHSHELL NORCO10022597-NAVY-MEDRMNS FR AIR HENLEY LS TOP NAVYRacelandLA70394728.8620.7341.5960
484241913/1/2024 0:00BOBBY RUMOREWDHH8M0AHSHELL NORCO10022599-GRAY-MEDRMNS FR AIR HENLEY LS TOP SILVRRacelandLA703947272
584241913/1/2024 0:00BOBBY RUMOREWDHH8M0AHSHELL NORCO10022597-NAVY-MEDRMNS FR AIR HENLEY LS TOP NAVYRacelandLA703947272
684256833/1/2024 0:00BRANDON GONZALEZ7Q6LCEJNBGOLDEN PASS LNG10023466-BLUE-2932MNS FR M4 RLX STR DLT BSC BT CPort ArthurTX776422069.1317.7511.37221.51
784253053/1/2024 0:00GUILLERMO MENDOZA2B6MZVIMTCARSONP-INDM10 42X3042x30 10OZ FR MODERN JEANSLONG BEACHCA908055928.140087.14
884253053/1/2024 0:00GUILLERMO MENDOZA2B6MZVIMTCARSON888830073032Rambler 36oz Bottle Chug NavyLONG BEACHCA90805590059
984253053/1/2024 0:00GUILLERMO MENDOZA2B6MZVIMTCARSON10023466-BLUE-4230MNS FR M4 Relaxed Stretch DuraLONG BEACHCA9080510300103
1084253053/1/2024 0:00GUILLERMO MENDOZA2B6MZVIMTCARSON10012258-GRAY-3XLTRMNS FR Work Crew T-ShirtLONG BEACHCA90805830083
1184324433/1/2024 0:00ANDREW GARCIA5UASCACLJCITGO306-396-XLTahoeMISSIONTX785744011.64.26055.86
1284308203/1/2024 0:00SHALTON LOPEZ-GARCIABMFBSK7ORGBR8051-33BKHigh Sierra Elite Fly-By 17 inNORTH BRUNSWNJ08902789.8503.2184.64
AR_Bartlett
Cell Formulas
RangeFormula
P2:P12P2=SUM(AR_Bartlett[@[ExtensionAmt]:[SalesTaxAmt]])-[@DepositAmt]
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
How about something like this.....

I could not get the L2BB function to work so had to just cut and paste;

OrderNoAmountFreightTaxDepositTotal
12345​
500.0012.0025.00130.00407.00=IF(A2=A1,"",SUMIF(A:A,A2,B:B)+SUMIF(A:A,A2,C:C)+SUMIF(A:A,A2,D:D)-SUMIF(A:A,A2,E:E))
78675​
230.0017.0012.00200.00221.00
78675​
120.0011.005.00
78675​
25.001.00
98765​
300.0017.0027.0075.00269.00
99999​
100.005.007.0050.0062.00
 
Upvote 0
Just wondering why you have asked in this forum not the 'Excel Questions' forum since it looks like an Excel question?

Assuming ..
- Excel,
- Keeping your formal Excel table nomenclature, and
- Using your 365 version,
.. see if this does what you want.

jarett.xlsm
ABLMNOP
1SalesOrderNoExtensionAmtFreightAmtSalesTaxAmtDepositAmtNet Invoice
284323107811.537.76097.29
38424191728.8620.7341.59204
4842419172 
5842419172 
684256832069.1317.7511.37221.51
784253055928.1400332.14
884253055900 
9842530510300 
1084253058300 
1184324434011.64.26055.86
128430820789.8503.2184.64
13
14
Sheet1
Cell Formulas
RangeFormula
P2:P12P2=LET(SO,[@SalesOrderNo],d,FILTER(AR_Bartlett[[ExtensionAmt]:[DepositAmt]],[SalesOrderNo]=SO),IF(SO=OFFSET(SO,-1,0),"",SUM(TAKE(d,,3),-TAKE(d,,-1))))
 
Upvote 0
Just wondering why you have asked in this forum not the 'Excel Questions' forum since it looks like an Excel question?

Assuming ..
- Excel,
- Keeping your formal Excel table nomenclature, and
- Using your 365 version,
.. see if this does what you want.

jarett.xlsm
ABLMNOP
1SalesOrderNoExtensionAmtFreightAmtSalesTaxAmtDepositAmtNet Invoice
284323107811.537.76097.29
38424191728.8620.7341.59204
4842419172 
5842419172 
684256832069.1317.7511.37221.51
784253055928.1400332.14
884253055900 
9842530510300 
1084253058300 
1184324434011.64.26055.86
128430820789.8503.2184.64
13
14
Sheet1
Cell Formulas
RangeFormula
P2:P12P2=LET(SO,[@SalesOrderNo],d,FILTER(AR_Bartlett[[ExtensionAmt]:[DepositAmt]],[SalesOrderNo]=SO),IF(SO=OFFSET(SO,-1,0),"",SUM(TAKE(d,,3),-TAKE(d,,-1))))
That is my bad, it had been a while since I have posted something. I did try your solution and some lines were correct but others I received a #value error, all of the cells seem to have the correct format. I assume it might have something to do with the version type of excel I pasted the formula into?
 
Upvote 0
OK, I've moved the thread to the Excel Questions forum. :)


I did try your solution and some lines were correct but others I received a #value error,
So could we have another small sample with XL2BB and ensure there are a few Sales Order numbers that work with my formula and a few that do not work with my formula? Before making the XL2BB Mini Sheet, hide the irrelevant columns like I did to keep the Mini Sheet smaller.


I received a #value error, .... I assume it might have something to do with the version type of excel I pasted the formula into?
If you pasted my formula into your 2016 version the formula should return a #NAME? error.
If it is working for some rows then I assume that you must be using it in MS365. Is that correct? (I did note in my previous post that I had assumed 365 version as the functions used are not all available in other versions)
 
Upvote 0
OK, I've moved the thread to the Excel Questions forum. :)



So could we have another small sample with XL2BB and ensure there are a few Sales Order numbers that work with my formula and a few that do not work with my formula? Before making the XL2BB Mini Sheet, hide the irrelevant columns like I did to keep the Mini Sheet smaller.



If you pasted my formula into your 2016 version the formula should return a #NAME? error.
If it is working for some rows then I assume that you must be using it in MS365. Is that correct? (I did note in my previous post that I had assumed 365 version as the functions used are not all available in other versions)
The excel version is through our 365 license, Microsoft® Excel® for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20124) 64-bit

INVOICE 03012024.xlsx
ABLMNOP
1InvoiceNoSalesOrderNoExtensionAmtFreightAmtSalesTaxAmtDepositAmtNet Invoice
2005368784323107811.537.76097.29
300536898424191728.8620.7341.59204
40053689842419172 
50053689842419172 
6005369084256832069.1317.7511.37221.51
7005369184253055928.1400332.14
8005369184253055900 
90053691842530510300 
10005369184253058300 
11005369384324434011.64.26055.86
1200536958430820789.8503.2184.64
13005369684202996821.4302.43#VALUE!
14005369684202991000 
1500536968420299350 
160053696842029968 0  
1700536978425805729.4412.050152.49
1800536978425805590 
190053698843332310012.459.9517.4105
200053700843230320610.4517.860234.31
210053701842776415212.4513.980178.43
2200537028429684799.5227.690330.21
230053702842968478 0 
240053702842968418 0 
2500537028429684118 0 
2600537038427981688.8612.280161.14
270053703842798172 0 
2800537048407581619.316.114.59#VALUE!
290053704840758168  
300053704840758137  
AR_Bartlett
Cell Formulas
RangeFormula
P2:P30P2=LET(SO,[@SalesOrderNo],d,FILTER(AR_Bartlett[[ExtensionAmt]:[DepositAmt]],[SalesOrderNo]=SO),IF(SO=OFFSET(SO,-1,0),"",SUM(TAKE(d,,3),-TAKE(d,,-1))))
 
Upvote 0
Thanks for the XL2BB sample. That has shown that the issue affecting my formula is that some of the "empty" cells in column O are not empty but contain space characters. Those cells are shown in yellow below. There are also space characters in the blue cells though they do not cause a problem in my formula.

To me, the ideal solution would be to clean up the original data so that such space characters are removed (yellow and blue) as that sort of thing often affects later results and is not obvious to look at.
Failing that, if you wanted to use a structured refence formula for the "Net Invoice" column, once the data is in this table you could either
  • Find/Replace space characters in those columns, or at least column O, (with 'Match entire cell contents' set) and my previous formula should work
    or
  • Leave those space characters alone and slightly change my formula as follows

    =LET(SO,[@SalesOrderNo],d,FILTER(AR_Bartlett[[ExtensionAmt]:[DepositAmt]],[SalesOrderNo]=SO),IF(SO=OFFSET(SO,-1,0),"",SUM(TAKE(d,,3),-N(TAKE(d,,-1)))))
Here it is with those space characters still in the yellow (& blue) cells.

jarett.xlsm
BLMNOP
1SalesOrderNoExtensionAmtFreightAmtSalesTaxAmtDepositAmtNet Invoice
284323107811.537.76097.29
38424191728.8620.7341.59204
4842419172 
5842419172 
684256832069.1317.7511.37221.51
784253055928.1400332.14
884253055900 
9842530510300 
1084253058300 
1184324434011.64.26055.86
128430820789.8503.2184.64
1384202996821.4302.43290
1484202991000 
158420299350 
16842029968 0  
178425805729.4412.050152.49
188425805590 
19843332310012.459.9517.4105
20843230320610.4517.860234.31
21842776415212.4513.980178.43
228429684799.5227.690330.21
23842968478 0 
24842968418 0 
258429684118 0 
268427981688.8612.280161.14
27842798172 0 
288407581619.316.114.59186.82
29840758168  
30840758137  
Sheet4
Cell Formulas
RangeFormula
P2:P30P2=LET(SO,[@SalesOrderNo],d,FILTER(AR_Bartlett[[ExtensionAmt]:[DepositAmt]],[SalesOrderNo]=SO),IF(SO=OFFSET(SO,-1,0),"",SUM(TAKE(d,,3),-N(TAKE(d,,-1)))))
 
Upvote 0
How about something like this.....

I could not get the L2BB function to work so had to just cut and paste;

OrderNoAmountFreightTaxDepositTotal
12345​
500.0012.0025.00130.00407.00=IF(A2=A1,"",SUMIF(A:A,A2,B:B)+SUMIF(A:A,A2,C:C)+SUMIF(A:A,A2,D:D)-SUMIF(A:A,A2,E:E))
78675​
230.0017.0012.00200.00221.00
78675​
120.0011.005.00
78675​
25.001.00
98765​
300.0017.0027.0075.00269.00
99999​
100.005.007.0050.0062.00
Notice some inconsistencies in your data compared to mine, and that is my fault, I must of pulled some data that had been edited after the refresh. This version is not working because C and D would only need to be summed once and E subtracted once, those columns have the same values if there are multiple lines. Going to reply to last post with new data.
 
Upvote 0

Forum statistics

Threads
1,215,212
Messages
6,123,649
Members
449,111
Latest member
ghennedy

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