Averageifs

SRacak

New Member
Joined
May 30, 2018
Messages
5
I have a workbook with multiple tabs. On my Summary Tab I'm trying to calculate various averages from other tabs. Averageifs works great when the "Quantity" is 1 in a column from one of the tabs, but if it's greater than 1 it doesn't calculate properly.

Data Tab
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]SPLC[/TD]
[TD="align: center"]Qty.[/TD]
[TD="align: center"]Job[/TD]
[TD="align: center"]Hrs.[/TD]
[TD="align: center"]Mat'l.[/TD]
[/TR]
[TR]
[TD="align: center"]111111[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1160[/TD]
[TD="align: center"]0.5[/TD]
[TD="align: center"]45.00[/TD]
[/TR]
[TR]
[TD="align: center"]111111[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1160[/TD]
[TD="align: center"]1.0[/TD]
[TD="align: center"]90.00[/TD]
[/TR]
[TR]
[TD="align: center"]111111[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1160[/TD]
[TD="align: center"]0.7[/TD]
[TD="align: center"]49.00[/TD]
[/TR]
[TR]
[TD="align: center"]333333[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1160[/TD]
[TD="align: center"]0.3[/TD]
[TD="align: center"]35.00[/TD]
[/TR]
[TR]
[TD="align: center"]333333[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1160[/TD]
[TD="align: center"]0.5[/TD]
[TD="align: center"]65.00[/TD]
[/TR]
[TR]
[TD="align: center"]555555[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1160[/TD]
[TD="align: center"]1.0[/TD]
[TD="align: center"]25.00[/TD]
[/TR]
[TR]
[TD="align: center"]555555[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1160[/TD]
[TD="align: center"]1.8[/TD]
[TD="align: center"]50.00[/TD]
[/TR]
[TR]
[TD="align: center"]555555[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1160[/TD]
[TD="align: center"]0.8[/TD]
[TD="align: center"]30.00[/TD]
[/TR]
</tbody>[/TABLE]


Summary Tab
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD="align: center"]SPLC[/TD]
[TD="align: center"]Job[/TD]
[TD="align: center"]Avg. Hrs.[/TD]
[TD="align: center"]Avg. Mat'l.[/TD]
[/TR]
[TR]
[TD="align: center"]111111[/TD]
[TD="align: center"]1160[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]333333[/TD]
[TD="align: center"]1160[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]555555[/TD]
[TD="align: center"]1160[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]







I was considering an Array formula, but got lost in the translations found on the web...

Any assistance will be greatly appreciated.

Thank you,
Steve
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try this in 'Summary Tab'!C2:

Code:
=SUMPRODUCT(--('Data Tab'!$A$2:$A$9=$A2),'Data Tab'!$B$2:$B$9,'Data Tab'!D$2:D$9)/SUMPRODUCT(--('Data Tab'!$A$2:$A$9=$A2),'Data Tab'!$B$2:$B$9)

copied down and right.
 
Last edited:
Upvote 0
I guess I should have mentioned that I have 23 different SPLCs, ~300 different Jobs and ~81,000 rows of data in my Data Tab. Do you think an Array formula would be more efficient?

Thank you,
Steve
 
Upvote 0
A formula with SUMPRODUCT is an array-processing formula. Generally, they are more expensive than the range-processing (database) formulas.

The denominator of the formula Oaktree suggests can be replaced with a faster SumIfs expression:

=SUMPRODUCT(--('Data Tab'!$A$2:$A$9=$A2),'Data Tab'!$B$2:$B$9,'Data Tab'!D$2:D$9)/SUMIFS('Data Tab'!$B$2:$B$9,'Data Tab'!$A$2:$A$9,$A2)
 
Upvote 0
Aladin,

Using your formula, the result was 0.8 Avg. Hrs. for SPLC 111111. Calculating manually, the result is 0.55.

What am I missing?

Thanks,
Steve
 
Upvote 0
Aladin,

Using your formula, the result was 0.8 Avg. Hrs. for SPLC 111111. Calculating manually, the result is 0.55.

What am I missing?

Thanks,
Steve

Is this what we need?

=SUMPRODUCT(--('Data Tab'!$A$2:$A$9=$A2),'Data Tab'!$B$2:$B$9,--('Data Tab'!$C$2:$C$9=$B2),'Data Tab'!D$2:D$9)/SUMIFS('Data Tab'!$B$2:$B$9,'Data Tab'!$A$2:$A$9,$A2,'Data Tab'!$C$2:$C$9,$B2)
 
Upvote 0
That formula returned a #REF !...



Book1
ABCDE
1SPLCQty.JobHrs.Mat'l.
2111111111600.545
311111121160190
4111111111600.749
5333333111600.335
6333333211600.565
755555511160125
8555555211601.850
9555555111600.830
Data Tab


Book1
ABCD
1SPLCJobAvg. Hrs.Avg. Mat'l.
211111111600.868.5
333333311600.433333355
455555511601.3538.75
Summary


You should have shown which values must obtain from Data Tab in your initial post. That said...

In C2 of Summary enter, copy across, and down:

=SUMPRODUCT(--('Data Tab'!$A$2:$A$9=$A2),'Data Tab'!$B$2:$B$9,--('Data Tab'!$C$2:$C$9=$B2),'Data Tab'!D$2:D$9)/SUMIFS('Data Tab'!$B$2:$B$9,'Data Tab'!$A$2:$A$9,$A2,'Data Tab'!$C$2:$C$9,$B2)

Note. This just expands Oaktree's suggestion with the Job condition.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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