totals and average

UndwaterExcelWeaver

New Member
Joined
Mar 2, 2019
Messages
27
Office Version
  1. 365
Platform
  1. Windows
In the table below I am trying to extract data based on the date and supplier. My destination sheet has a date that must match the date in column B in order for the data to be brought in. (date is Cell D1 in the destination sheet) I need to bring in the total lbs for each date in column J, and the average results for fat, protein and solids for each date. The kicker is that those results are dependent on the supplier. If the supplier is IMP, then the average results should come from columns P:R. If the supplier is not IMP, the results should come from columns M:O. I'm not sure if I need to use lookup, vlookup, or just a sumif/averageif set of formulas to make this happen. Currently I do not have more than one set of results per day, but this is set to change next week, so I need to be able to calculate and extract totals and averages, opposed to just the first set of results found for the inquired date. Please let me know what details I may be missing for you.

UF retentate received 2024.xlsx
BCJMNOPQR
1SKIM UF RETENTATE CHEMISTRY ANALYSIS
2From Composite Bottle
3Load information for traceabilitySupplier resultsNampa Lab FT
4Receiving dateSupplierWeightSolidsFatTrue Protein (TP)SolidsFatTrue Protein (TP)
5Lb.%%%%%%
61/27/2024IMP49,16016.120.3914.2817.320.3714.29
71/28/2024CDI48,38018.410.1914.6618.550.3514.79
81/29/2024IMP48,18015.050.3613.3916.300.3513.36
91/30/2024IMP47,96015.800.3714.0917.030.3614.07
101/31/2024IMP48,66015.730.4213.5017.000.3413.75
112/1/2024CDI47,74017.940.2014.1218.010.3414.15
122/2/2024IMP47,36016.170.0713.6617.280.3414.02
132/3/2024IMP48,52016.440.1213.9317.390.3514.11
142/4/2024IMP49,24016.480.1214.1217.550.3614.37
152/5/2024IMP49,10016.070.0713.6217.340.3514.07
162/6/2024IMP48,46016.340.0613.8017.140.2713.95
172/10/2024IMP50,10016.379.0013.8717.440.3514.18
182/11/2024IMP48,14016.360.0714.2917.420.3714.51
192/12/2024IMP48,54015.900.1013.88
20
21
22
23
24
25
MAIN
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Not sure how helpful this is but my first impression tells me an =AVEIFS might be the way to go. That way, in your destination tab you can have each date in column B as you're outlining. Column C would have the supplier, IMP or CDI. Maybe you would have two rows for each date, one for IMP and one for CDI.

This link may be helpful as a starting point:

 
Upvote 0
Not sure how helpful this is but my first impression tells me an =AVEIFS might be the way to go. That way, in your destination tab you can have each date in column B as you're outlining. Column C would have the supplier, IMP or CDI. Maybe you would have two rows for each date, one for IMP and one for CDI.

This link may be helpful as a starting point:

This is the formula I've tried for extracting the fat for one day. I tried to combine the two options into an IF statement to yield one average if the other doesn't match all criteria. It is returning a #spill error. I tried adding the specific cell ranges instead of the entire column, but the spill error persists. I'm not sure what I'm doing wrong, but probably a lot. I only have one cell to pull the result to in the destination sheet so multiple rows is not an option.

=IF('[UF retentate received 2024.xlsx]MAIN'!$C6:$C32<>"CDI",AVERAGEIFS('[UF retentate received 2024.xlsx]MAIN'!$Q6:$Q32,'[UF retentate received 2024.xlsx]MAIN'!$B6:$B32,D1,'[UF retentate received 2024.xlsx]MAIN'!$C6:$C32,'[UF retentate received 2024.xlsx]MAIN'!$C6:$C32<>"CDI"),AVERAGEIFS('[UF retentate received 2024.xlsx]MAIN'!$N6:$N32,'[UF retentate received 2024.xlsx]MAIN'!$B6:$B32,D1,'[UF retentate received 2024.xlsx]MAIN'!$C6:$C32,"CDI"))
 
Upvote 0
This is the formula I've tried for extracting the fat for one day. I tried to combine the two options into an IF statement to yield one average if the other doesn't match all criteria. It is returning a #spill error. I tried adding the specific cell ranges instead of the entire column, but the spill error persists. I'm not sure what I'm doing wrong, but probably a lot. I only have one cell to pull the result to in the destination sheet so multiple rows is not an option.

=IF('[UF retentate received 2024.xlsx]MAIN'!$C6:$C32<>"CDI",AVERAGEIFS('[UF retentate received 2024.xlsx]MAIN'!$Q6:$Q32,'[UF retentate received 2024.xlsx]MAIN'!$B6:$B32,D1,'[UF retentate received 2024.xlsx]MAIN'!$C6:$C32,'[UF retentate received 2024.xlsx]MAIN'!$C6:$C32<>"CDI"),AVERAGEIFS('[UF retentate received 2024.xlsx]MAIN'!$N6:$N32,'[UF retentate received 2024.xlsx]MAIN'!$B6:$B32,D1,'[UF retentate received 2024.xlsx]MAIN'!$C6:$C32,"CDI"))
Trying this and it returns a #div0 error

=OR(AVERAGEIFS('[UF retentate received 2024.xlsx]MAIN'!$Q:$Q,'[UF retentate received 2024.xlsx]MAIN'!$B:$B,D1,'[UF retentate received 2024.xlsx]MAIN'!$C:$C,'[UF retentate received 2024.xlsx]MAIN'!$C:$C<>"CDI"),AVERAGEIFS('[UF retentate received 2024.xlsx]MAIN'!$N:$N,'[UF retentate received 2024.xlsx]MAIN'!$B:$B,D1,'[UF retentate received 2024.xlsx]MAIN'!$C:$C,"CDI"))
 
Upvote 0
Since you have only one cell to pull the result in, someone smarter than me may be able to help with an "IF" function. In simple terms, it would look to see if column C equals IMP, if it does, then do "this". If it doesn't equal IMP, then do "a different calculation". Eager to see the final solution. I'm pushing my abilities with my suggestions and don't know if they're on track or not.
 
Upvote 0
I've made some progress. I've created a sheet and named one tab "Source" and another "Destination".

1. On the "Source" tab, starting with row 20, I have added a few more lines so we could have some data to average across the same date. I've added three rows for 1/27/2024, and one each for 1/28/2024 - 2/1/2024. Enter whatever data you want, just so you have something to work with.

2. In the "Destination" tab, in cell D3, I have this code =Source!C6 which pulls in the data from the date column so as to assure matching.
3. In the "Destination" tab in cell E3, I have this code =AVERAGEIFS(Source!$J$6:$J$27,Source!$C$6:$C$27,Destination!$D3)

This does indeed pull an average from ALL cells in column J where the dates match.

This gets us part way there. What is now needed is for the E3 of the Destination tab, to ALSO look in column D of the Source tab and only do the average if D = CDI. I think you will need another column in your Destination tab to do the same thing but average the number if D=IMP.

Make sense? Again, I'm stretching my ability here, just trying to steer in a direction that may help.
 
Upvote 0
UPDATE -- In the Destination tab in cell C3 I have entered CDI. In C4 I have entered IMP. This formula

=AVERAGEIFS(Source!$J$6:$J$27,Source!$C$6:$C$27,Destination!$D3,Source!$D$6:$D$27,Destination!$C$3)

Pulls up CDI information but it's not doing an average, it's only showing the last entry I made using fictious data. It's the correct information reflecting the last CDI entry for 1/27/2024 but again, it's not the average.

Hope this helps. I need get back to other projects.
 
Upvote 0

Forum statistics

Threads
1,215,072
Messages
6,122,966
Members
449,094
Latest member
Anshu121

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