Oct 20 2022 01:36 AM - edited Oct 20 2022 01:46 AM
I trying to get the correct average of just the q1 and q3 values using averageifs function. Have looked a lot online but couldn't find a solution. However, someone kindly did help me here on MS community with a formula that works: =AVERAGE(IF(H2:H13<>"", IF(H2:H13<>0, IF((G2:G13="q1")+(G2:G13="q3")>0, H2:H13)))). They also explained that it is an OR logic type scenario.
But I am hoping to use the averageifs function (or a much smaller formula/function) to get the answer since by definition that function should work with multiple criteria even in the same column.
Some more info that may be helpful before answering my question:
Version: O365 Excel
The blank cells in the average range are empty with no values.
I have already tried this formula: =AVERAGE(AVERAGEIFS(H2:H13,G2:G13,{"q1","q3"})), but I was told it does not always work (for eg. if a value is added to any of the blank cells, the average comes incorrect).
Here is the link (because I don't have the permission to upload the images here directly and don't know how to) to the screenshot of my sheet from my OneDrive: https://1drv.ms/u/s!AmNyoq6I8cL6iWqAoPs7zfdjWREs?e=IcIoJ7
Oct 20 2022 01:47 AM
Oct 20 2022 02:16 AM
Oct 20 2022 05:09 AM
Oct 20 2022 05:46 AM - edited Oct 20 2022 05:47 AM
@Jan Karel Pieterse perhaps you can try divide by two yourself since I am indeed getting the correct average with that but just think the formula is too long. Also, after trying your two alternatives:
1. =AVERAGE(IF((G2:G13="q1")+(G2:G13="q3")>0,H2:H13," "))
2. =(SUMIFS(H2:H13,G2:G13,"q1")+SUMIFS(H2:H13,G2:G13,"q3"))/(COUNTIFS(G2:G13,"q1")+COUNTIFS(G2:G13,"q3"))
I get 18,847 for both, instead of the correct average which is 56,540.5.
Oct 20 2022 06:22 AM
SolutionOct 20 2022 10:50 PM - edited Oct 20 2022 10:58 PM
Ok this one works. And I now see why you are not convinced about the divide by two formula. Turns out, it returns the wrong answer if I enter a value in one of the blank cells say 123456 in H3. Just still wish there was a much shorter formula to compute this
Oct 21 2022 02:46 AM