AVERAGE HH:MM time using OR and AND together within the same formula

LawNapier

New Member
Joined
May 18, 2020
Messages
26
Office Version
  1. 365
Platform
  1. Windows
I am trying to average column D (time results in custom format HH:MM).

I need to only average the rows that meet the criteria.

A:A = APPLE or PEAR
and B:B= RIPE and C:C= GOOD

I need the result to return in custom format HH:MM

ABCD
1APPLERIPEGOOD01:23
2APPLERIPEGOOD15:33
3PEARRIPEGOOD22:00
4PEARROTTENBAD14:47
5APPLEROTTENBAD00:48

Thank you in advance for your help.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Custom number format: [h]:mm:ss, this is the most important part or it will just sum the hours like a clock instead of as a number.

Here I give you an example of 2 criterias , if you need 3 criterias (+ APPLE or PEAR) cause you have many other fruits and cant do it by yourself tell me and I will help you.

Traductor de Formulas - copia.xlsm
ABCDEFG
1APPLERIPEGOOD1:23:00Criteria1Criteria2
2APPLERIPEGOOD15:33:00RIPEGOOD
3PEARRIPEGOOD22:00:00
4PEARROTTENBAD14:47:00
5APPLEROTTENBAD0:48:00
612:58:40Average of criteria
Hoja4
Cell Formulas
RangeFormula
D6D6=AVERAGEIFS(D1:D5,B1:B5,"="&F2,C1:C5,"="&G2)
 
Upvote 0
Hi Tricepsratops - Thanks for your response. However, the premise of the question is how I can combine an "or" and "and" into one formula. I need to know how to look for the below.

A:A = APPLE or PEAR
and B:B= RIPE and C:C= GOOD

You streamlined it by not including the "OR" component. I understand why you did that, but I need to include the "OR" component and that is the part I can't figure out. Any ideas how to do that?
 
Upvote 0
I dont really know how to make it work, I tried but everytime I write OR function or AND it breaks.

Lets wait for someone more experienced.
 
Upvote 0
Hi, you could try like this.

Book2
ABCDEF
1APPLERIPEGOOD01:2312:58
2APPLERIPEGOOD15:33
3PEARRIPEGOOD22:00
4PEARROTTENBAD14:47
5APPLEROTTENBAD00:48
Sheet1
Cell Formulas
RangeFormula
F1F1=SUM(SUMIFS(D:D,A:A,{"APPLE","PEAR"},B:B,"RIPE",C:C,"GOOD"))/SUM(COUNTIFS(A:A,{"APPLE","PEAR"},B:B,"RIPE",C:C,"GOOD"))
 
Upvote 0
Hi FormR - When using the {"APPLE","PEAR"} Array, I need to use cell references instead of manually placing the criteria string
Apple" and "Pear" in there. Do you know what the syntax would be for that?
 
Upvote 0
Tricepsratops - Thanks for trying. This has been a tough one for me as well.
 
Upvote 0
I need to use cell references instead of manually placing the criteria

Hi, you could give this a try.

Book3
ABCDEFG
1APPLERIPEGOOD01:23:00APPLE12:58:40
2APPLERIPEGOOD15:33:00PEAR
3PEARRIPEGOOD22:00:00
4PEARROTTENBAD14:47:00
5APPLEROTTENBAD00:48:00
Sheet1
Cell Formulas
RangeFormula
G1G1=SUMPRODUCT(SUMIFS(D:D,A:A,F1:F2,B:B,"RIPE",C:C,"GOOD"))/SUMPRODUCT(COUNTIFS(A:A,F1:F2,B:B,"RIPE",C:C,"GOOD"))
 
Upvote 0
I ended up using thanks.

=SUM(

AVERAGEIFS(C:C,
A:A,"="&"APPLE",
B:B,"="&"RIPE"),

AVERAGEIFS(C:C,
A:A,"="&"PEAR",
B:B,"="&"RIPE"),


)
 
Upvote 0
I ended up using

OK, as long as you understand that is not the same as the average of the times where column A is either Pear OR Apple.

To demonstrate.

Book1
ABCDEFGH
1APPLERIPE01:23:00APPLE12:58:4006:28:0012:58:40
2APPLERIPE15:33:00PEAR
3PEARRIPE22:00:00
Sheet1
Cell Formulas
RangeFormula
F1F1=SUMPRODUCT(SUMIFS(C:C,A:A,E1:E2,B:B,"RIPE"))/SUMPRODUCT(COUNTIFS(A:A,E1:E2,B:B,"RIPE"))
G1G1=SUM(AVERAGEIFS(C:C, A:A,"="&"APPLE", B:B,"="&"RIPE"), AVERAGEIFS(C:C, A:A,"="&"PEAR", B:B,"="&"RIPE"))
H1H1=AVERAGE(C1:C3)
 
Upvote 0

Forum statistics

Threads
1,215,432
Messages
6,124,856
Members
449,194
Latest member
HellScout

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