AVERAGEIF of SMALL with multiple criteria

gpnm25

New Member
Joined
Oct 10, 2013
Messages
4
Hi all!

Long time lurker...first time poster.

I'm not an excel expert, but certainly not a noobie.

So this is very, very frustrating.

I have a very large dataset -- around 25K rows (probably more). I have a bunch of fields including STATE, AGE, GENDER, and RATING AREA. In addition, I have a field with insurance premiums.

What I want to do is take the average of the 5 lowest insurance premiums for every state, age, gender, and rating area. I have another table where I'm trying to plug this in.

The formula that I've tried (and failed at using) is:

Code:
=AVERAGEIF(small(Table2[Premiums],{1,2,3,4,5}),Table2[State],[@State]...

I just get a message from excel saying that there's an error in my formula...

Table 2 is the table with all of the information, and I'm plugging this formula into a table that has the proper qualifiers (Age, Gender, Rating Area, State).

Help???
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I've tried with a pivot table, but I'm having trouble getting the actual values for the premiums to show rather than a calculation (ideally, I'd be able to do it as a calculated field within the pivot table, but it's not letting me use small(premiums,{1,2,3,4,5}) in the pivot table).
 
Upvote 0
As an FYI, in case anyone else runs into the same trouble.

I ended up using a pivot table to display the 5 cheapest premiums for each combination of qualifiers (using the "Top 10" filter option). I reconfigured the pivot table to look more like a regular dataset (took some effort), then copied and pasted into a separate excel sheet. From there, I was able to pull the information using a simple averageif statement (but without the array that I was trying to use before -- so it was just an average of all the premiums, which ended up now being the 5 cheapest).

Hope this helps someone else down the line!
 
Upvote 0
1. Control+shif+enter, not just enter:

=AVERAGE(SMALL(PremiumRange,{1,2,3,4,5}))

2. Just enter:

=AVERAGEIF(PremiumRange,"<="&SMALL(PremiumRange,5))
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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