calculate sum or weighted average of data found using Xlookup

UndwaterExcelWeaver

New Member
Joined
Mar 2, 2019
Messages
38
Office Version
  1. 365
Platform
  1. Windows
I have successfully extracted data from this table using the Xlookup function, but only when there is only one result per day. I need to know how to add to or alter this formula to correctly sum (lbs) or weighted average (fat/prot/solids) if there is more than one row per date. (rows 19 and 20 in the second table represent the instance of more than one per date).

The current extraction formulas are in the top table, with the bottom table being the source information.


Ched-Mozz Mass Balance 0224.xlsm
CDEF
2350,0000.36--
20
Cell Formulas
RangeFormula
C23C23=IFERROR(XLOOKUP($D$1,UFRET!B:B,UFRET!J:J,,0,1),)
D23D23=IFERROR(AVERAGE(XLOOKUP($D$1,UFRET!$B:$B,UFRET!$Q:$Q,,1,1)),)
E23E23=IFERROR(XLOOKUP($D$1,UFRET!$B:$B,UFRET!R:R,,0,1),)
F23F23=IFERROR(XLOOKUP($D$1,UFRET!$B:$B,UFRET!P:P,,0,1),)


Cell Formulas
RangeFormula
B2:B30,J2:J30,P2:R30B2='[UF retentate received 2024.xlsx]MAIN'!B5
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I'm not going to create separate workbook. But, I think you can figure out what to do with this.
Two options, both with Excel 365.

Book1
BJPQRSYZ
1Receiving DateWeightSolids3Fat4True Protien
2
32024-01-2749,10217.40%0.38%
42024-01-2848,32116.70%0.37%
52024-01-2948,85117.10%0.38%
62024-01-3048,93617.00%0.38%
72024-01-3149,19016.70%0.36%
82024-02-0148,83217.40%0.37%
92024-02-0249,43717.60%0.37%
102024-02-0348,70817.10%0.36%
112024-02-0448,68517.60%0.36%
122024-02-0548,67517.70%0.38%
132024-02-0648,93916.70%0.37%
142024-02-0748,06017.60%0.38%
152024-02-0848,53117.10%0.38%
162024-02-0948,44417.00%0.37%
172024-02-1048,75516.90%0.36%
182024-02-1149,54717.90%0.36%
192024-02-1249,67017.30%0.38%
202024-02-1348,16917.80%0.38%
212024-02-1449,71216.60%0.37%
22
23
24Excel 365 Filter FunctionINDEX XMATCH
252024-01-2749,10217.40%0.38%49,10217.40%0.38%
262024-01-3048,93617.00%0.38%48,93617.00%0.38%
272024-02-0448,68517.60%0.36%48,68517.60%0.36%
282024-02-0548,67517.70%0.38%48,67517.70%0.38%
292024-02-0648,93916.70%0.37%48,93916.70%0.37%
302024-02-1249,67017.30%0.38%49,67017.30%0.38%
312024-02-1348,16917.80%0.38%48,16917.80%0.38%
322024-02-1449,71216.60%0.37%49,71216.60%0.37%
33
Sheet4
Cell Formulas
RangeFormula
J25:Q32J25=FILTER($J$3:$Q$21,$B$3:$B$21=B25,"")
S25:Z32S25=INDEX($J$3:$Q$21,XMATCH(B25,$B$3:$B$21,0,1),0)
Dynamic array formulas.
 
Upvote 0
I'm not going to create separate workbook. But, I think you can figure out what to do with this.
Two options, both with Excel 365.

Book1
BJPQRSYZ
1Receiving DateWeightSolids3Fat4True Protien
2
32024-01-2749,10217.40%0.38%
42024-01-2848,32116.70%0.37%
52024-01-2948,85117.10%0.38%
62024-01-3048,93617.00%0.38%
72024-01-3149,19016.70%0.36%
82024-02-0148,83217.40%0.37%
92024-02-0249,43717.60%0.37%
102024-02-0348,70817.10%0.36%
112024-02-0448,68517.60%0.36%
122024-02-0548,67517.70%0.38%
132024-02-0648,93916.70%0.37%
142024-02-0748,06017.60%0.38%
152024-02-0848,53117.10%0.38%
162024-02-0948,44417.00%0.37%
172024-02-1048,75516.90%0.36%
182024-02-1149,54717.90%0.36%
192024-02-1249,67017.30%0.38%
202024-02-1348,16917.80%0.38%
212024-02-1449,71216.60%0.37%
22
23
24Excel 365 Filter FunctionINDEX XMATCH
252024-01-2749,10217.40%0.38%49,10217.40%0.38%
262024-01-3048,93617.00%0.38%48,93617.00%0.38%
272024-02-0448,68517.60%0.36%48,68517.60%0.36%
282024-02-0548,67517.70%0.38%48,67517.70%0.38%
292024-02-0648,93916.70%0.37%48,93916.70%0.37%
302024-02-1249,67017.30%0.38%49,67017.30%0.38%
312024-02-1348,16917.80%0.38%48,16917.80%0.38%
322024-02-1449,71216.60%0.37%49,71216.60%0.37%
33
Sheet4
Cell Formulas
RangeFormula
J25:Q32J25=FILTER($J$3:$Q$21,$B$3:$B$21=B25,"")
S25:Z32S25=INDEX($J$3:$Q$21,XMATCH(B25,$B$3:$B$21,0,1),0)
Dynamic array formulas.
I am confused as to how these address the need sum total lbs per date or average out the test results. I got these results to populate but it just does the first row of data it encounters and accomplishes the same thing that the XLookup already did.
 
Upvote 0
I am confused as to how these address the need sum total lbs per date or average out the test results. I got these results to populate but it just does the first row of data it encounters and accomplishes the same thing that the XLookup already did.
You're right. The xmatch won't work.
The filter will, but will be a few minutes. ;)

Have you tried Power Query? Linking the source data in the Excel Data Model with Power Query you can then create Pivot Tables from the Data Model.
There are some great youtube video on PQ. Here is playlist by one:
 
Upvote 0
You're right. The xmatch won't work.
The filter will, but will be a few minutes. ;)

Have you tried Power Query? Linking the source data in the Excel Data Model with Power Query you can then create Pivot Tables from the Data Model.
There are some great youtube video on PQ. Here is playlist by one:
I'm heading home for the day but I'll check back with your results in the morning. Thanks for the assistance.
 
Upvote 0
Here is something you may be able to work with:
Although, if the data you have is a roll up of disparate counts, the averages are only averages of days and not averages of amounts of individual measurments(if that is what they are). You'd need to perform weighted average calculations.

Book1
AIOPQRSTUVW
1Receiving DateWeightSolids3Fat4True ProtienWeightSolids3Fat4
2AvgAvg
32024-01-2749,10217.40%0.38%2024-01-2749,269.5017.50%0.3750%
42024-01-2749,43717.60%0.37%2024-01-2848,321.0016.70%0.3700%
52024-01-2848,32116.70%0.37%2024-01-2948,851.0017.10%0.3800%
62024-01-2948,85117.10%0.38%2024-01-3049,063.6717.33%0.3667%
72024-01-3048,93617.00%0.38%2024-01-3149,190.0016.70%0.3600%
82024-01-3048,70817.10%0.36%2024-02-0148,832.0017.40%0.3700%
92024-01-3049,54717.90%0.36%2024-02-0449,177.5017.45%0.3700%
102024-01-3149,19016.70%0.36%2024-02-0548,422.0017.75%0.3800%
112024-02-0148,83217.40%0.37%2024-02-0649,325.5016.65%0.3700%
122024-02-0448,68517.60%0.36%2024-02-1048,755.0016.90%0.3600%
132024-02-0449,67017.30%0.38%2024-02-1248,060.0017.60%0.3800%
142024-02-0548,67517.70%0.38%2024-02-1348,531.0017.10%0.3800%
152024-02-0548,16917.80%0.38%2024-02-1448,444.0017.00%0.3700%
162024-02-0648,93916.70%0.37%
172024-02-0649,71216.60%0.37%
182024-02-1048,75516.90%0.36%
192024-02-1248,06017.60%0.38%
202024-02-1348,53117.10%0.38%
212024-02-1448,44417.00%0.37%
22
Sheet1
Cell Formulas
RangeFormula
T3:T15T3=SORT(UNIQUE(A3:A21,FALSE,FALSE),1,1)
U3:U15U3=LET(d,T3,dates,$A$3:$A$21,weights,$I$3:$I$21,AVERAGEIFS(weights,dates,d))
V3:V15V3=LET(d,T3,dates,$A$3:$A$21,solids,$O$3:$O$21,AVERAGEIFS(solids,dates,d))
W3:W15W3=LET(d,T3,dates,$A$3:$A$21,fats,$P$3:$P$21,AVERAGEIFS(fats,dates,d))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,223,931
Messages
6,175,465
Members
452,646
Latest member
tudou

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