How to spill multiple matches with defined name as range?

Rnkhch

Well-known Member
Joined
Apr 28, 2018
Messages
528
Office Version
  1. 365
Platform
  1. Windows
Hello,

I defined two dynamic ranges (names) through INDIRECT like this:

SampleNames=INDIRECT("Main!$D$2:$D$"&Control!$C$2)
SampleAverages=INDIRECT("Main!$H$2:$H$"&Control!$C$2)
where the end of the range is specified by Control!$C$2

Now I want to use these names and get the averages for specific samples, but some samples exist more than once, and I want to get a spill of all available averages. I was thinking to use INDEX within AGGREGATE, but it doesn't work, but maybe I'm overthinking this or missing something:

B2=AGGREGATE(15,3,INDEX(SampleAverages,(SampleNames=A2)/(SampleNames=A2),1),3)

I put 3 for the count, but I was also wondering what the best way is to put a counter for k?


Book1
ABCDEFGHI
1NamesAverages
2test1:test113
3test289
4test339
5test113
6test113
7test658
8test719
9
Sheet1


(There are other columns in the actual data, but I'm skipping here.)

I would appreciate any input!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Will this work for you:

=AVERAGE(FILTER(SampleAverages,SampleNames=A2))

You said average, so I'm not sure why you're trying AGGREGATE(15, ...)

And are your samples the same size, so that it is valid to average your averages without weighting?
 
Upvote 0
On re-reading, I think you maybe wanted one formula:

ABCDEFGH
1NamesAverages
2test1138test113
3test289test289
4test339test339
5test658test113
6test719test113
7test658
8test719
Main
Cell Formulas
RangeFormula
A2:A6A2=UNIQUE(D2:D8)
B2:B6B2=IFERROR(BYROW(A2#,LAMBDA(r,AVERAGE(FILTER(SampleAverages,SampleNames=r)))),"n/a")
Dynamic array formulas.
Named Ranges
NameRefers ToCells
SampleNames=INDIRECT("Main!$D$2:$D$"&Main!$C$2)A2
 
Upvote 0
Thanks. Maybe I should have stated more clearly, but I don't need to AVERAGE the numbers. I need to generate the list of those numbers (in this case they happen to be average of samples).

That's the reason I used INDEX. It works well when there is only one sample with the indicated name. But when there are multiple, I found online that people used SMALL or AGGREGATE 15 to return the list of multiple matches, and I was trying to emulate that here 😅.
 
Upvote 0
OK thanks, in that case I'm not clear what the intended results look like.

Can you please illustrate?
 
Upvote 0
Oh yes, I should have put that manually in the XL2BB, but here is what I need in B2 (spill of the three numbers in H that correspond to test1 samples):

Book1
ABCDEFGHIJ
1NamesAverages
2test1:13test113
327test289
440test339
5test127
6test140
7test658
8test719
9
Sheet1



If there was one "test1" sample, I would have used the regular INDEX/MATCH like this: B2=INDEX(SampleAverages,MATCH("test1",SampleNames,0),1)

So basically I need a fancier INDEX/MATCH for when there are multiple matches 😁.

(I changed the numbers slightly here as I didn't realize I had 13 for all test1 samples in my original post.)
 
Last edited:
Upvote 0
In pseudo-formula speak, that's just: =FILTER(Averages,Names=A2).

Depending on what you're looking for, Averages might be defined in terms of data in column H, and Names column D.

Or perhaps: =FILTER(SampleAverages,SampleNames=A2))
 
Upvote 0
Solution
Oh, that's right. I totally missed the obvious 🤦‍♂️. I was overthinking it :ROFLMAO:. That's what happens after a full day of working on Excel 😅
 
Upvote 0
Oh, that's right. I totally missed the obvious 🤦‍♂️. I was overthinking it :ROFLMAO:. That's what happens after a full day of working on Excel 😅
He he. Time for a break perhaps?

It's nearly wine-time here.
 
Upvote 0
Yeah lol.

Incidentally, I liked your B2 formula in post #3. I always learn a lot form your formulas 🤗

Cheers 🍷🍷
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,421
Members
448,961
Latest member
nzskater

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