Excel Average based on multiple conditions - excel

I am trying to create a formula to get the average value of one column that meets the criteria from two other columns. I have figured out a simpler one using an array, but i am attempting something more complex.
"=AVERAGE(IF((B:B="SRVC")+(B:B="TIRSVC"),E:E))" is the one I have created successfully. I am trying to add to this by also including row D and a new formula if the value is 5 or less, 6-10, 11-15 and so on to greater than 50. Any thoughts or suggestions?

Related

Getting Top Values from One Sheet and inputting onto a different sheet

So I'm going to eventually have 3 sheets. Sheet 1 is where I have data (numbers for a category and a name associated with it. Sheet 2 is where I pull the top 5 users for each category. Sheet 3 is where I have a leaderboard for points gained.
Right now I'm trying to work with Sheet 2 (grab the top 5 performers from each category. I'm fairly new to Excel, but after some research it seemed that XLOOKUP would be the way to go. (i'll attach screenshots below.
I'm using this formula:
=XLOOKUP(LARGE('Cases Test for Categories'!$C$18:$C$55,1),'Cases Test for Categories'!$C$18:$C$55,'Cases Test for Categories'!$A$18:$A$55)
however when using it I get all 0's.
Here's a screenshot of values I'm trying to grab from "Warranty Service Request"
and here is a screenshot when applying my formula
The solution I would want is to grab the 5 largest numbers from sheet 1 with the person name as well.
I don't think that XLOOKUP can get you anywhere near what you want but the formula below will get you one step closer.
=INDEX(List,MATCH(LARGE(INDEX(List, ,2),1),INDEX(List,,2),0),1)
In fact, it's the explanation of that formula which will be of help. Here we go.
List is a named range, perhaps equal to your 'Cases Test for Categories'!$C$18:$C$55. The reason for using a name is obvious. It's shorter. In my test List = A2:B6, in case you want to reconstruct it. Column 1 has names, column 2 numbers.
The term INDEX(List,,2) specifies the second column of List. You can replace the '2' with a formula to specify different columns of the named range.
In fact, INDEX(List,,1) does specify the first column and INDEX(List,4,1) specifies the 4th cell in that column, and that is exactly what you see in my formula. All of MATCH(LARGE(INDEX(List, ,2),1),INDEX(List,,2),0) just serves to find the row number in List, in this example the number 4.
Of course, LARGE(INDEX(List, ,2),1) returns the largest number in column2 of List. The '1' can be replaced by a formula, for example ROW()-1 which would return 1 if placed in row 2 and count up from there as it's copied down. Try =ROW()-1 in any cell in row 2 and copy the formula down.
MATCH([LARGEST],INDEX(List,,2),0) returns the row number where the largest was found, and that is the number we need to return the name from the first column of List.
This will work perfectly for one column and can easily be modified to work for different columns. Your question doesn't specify how you would like to arrange the 5 results from each category but the formula can be modified a little to accommodate whatever you want. What it can not do is to deal with ties. MATCH(LARGE can only find the first of several identical results.
To break ties in this sort of operation is complicated and must be done ether by helper columns in the data table or using VBA. It's definitely the topic of another question. For now I hope that it's a problem you will not have to anticipate.

Average of Averageifs (ignoring 0 values)

I have a data set which I am trying to find conditional averages from, I am able to get the results I want using multiple cells, but would like to contain all of the steps in a single cell
I have tried some other solutions on this site (most recently this one: AVERAGE from AVERAGEIFs that will ignore AVERAGEIFs where is ERROR EXCEL) from similar topics but cannot seem to make any of them work
The three steps I am using are
=IFERROR(AVERAGEIFS($F$3:$F$17,$B$3:$B$17,"TCM",$C$3:$C$17,"Critical"),0)
=IFERROR(AVERAGEIFS($F$3:$F$17,$B$3:$B$17,"TCM",$C$3:$C$17,"Main"),0)
=SUM(F23:F24)/COUNTIF(F23:F24,"<>0")
The first formula gives a value, the second zero and the third the average of the two, excluding the zero
I would like to know if it is possible to somehow combine these formulas into one cell?
UPDATE
sample table
In this table i would be looking to get the average of all the "A" in column B that also have "D" and "E" in column C (Using the values in column F to get the average) however in some instances a combination (e.g. "A" and "G") may be zero. In this instance I want to exclude the zero value from the calculation.

Returning sum of column for filtered data, without filter

I'm trying to calculate the sum of a column (TSQFT in the screenshot) that is part of a data set, which would be filtered based on multiple criteria using cell references (see screenshot). I don't want to use excel's regular filter as it's a hassle to change the settings and I'd like it to be done in a more automated way.
I've tried {SUMIF} and {SUMIFS} but those do not work as a filter - i.e. for a row to be {TRUE}, the numbers have to be in the same order as that specified in the criteria list {5-7-2} (see screenshot).
Would much appreciate any help.
You can try something like this:
Make 3 column of =IF(OR(C3=$C$10;C3=$D$10;C3=$E$10);1;0) formulas, one more column for a sum of this 3 column and a sumif based of the sum values
if the sum is 3 then the value is good.
This maybe the worst solution for this but as long as it can help, it can be developed into something better.

Excel: Need to count occurrences that values in column are greater than another column AND value in a third column is specified

The dummy data below is similar to the data I'm working with. I want to check how many instances that the value is greater than the goal, only in one region at a time.
To clarify, I have already figured out how to count the number of occurrences in which values in one column are greater than corresponding values in another row as follows:
=SUMPRODUCT(--(A:A>B:B))
or (as an array formula):
=SUM(IF(A:A>B:B,1,0))
I have another column specifying different regions in the country. I want to count these same occurrences for individual regions. For example, when the region is "Southeast". I have tried adding an & statement within these previous formulas, as well as multiple sumifs, countifs, and various variations of all of the above. I am continuously either getting a 0 or an error as my answer.
Thanks in advance!
You can use:
=SUMPRODUCT(--(C:C>B:B)*(A:A="Southeast"))
C is the column of Values
B is the column of Goals
A is the column of Region

Excel VBA 2010 - worksheet.subtotal function sum and average in the same row

I am creating a macro which takes data from an Oracle database, which means that the number of rows can vary depending upon the result. In this macro, I am using the worksheet.subtotal function, which sums up on a number of columns when the group changes. This all works, but the problem that I am facing are that a few of the columns need to be average.
Searching around I have not been able to find a solution where you can have both average and sum in the same row. I do not wish to have a situation where the user has to manually intervene to change each column for each group.
Is there away where you can have both average and sum in the same row?
AFAIK you cannot use both i.e Sum and Average together in Subtotal but don't loose heart :) Here is an alternative.
Let's say you have two columns. In one you want Sum and the other you want Average. In your code, set Sum for both columns. When the report is generated, simply highlight the column where you want Average and simply find and replace subtotal(9 with subtotal(1 using CTRL + H If you don't want to do it manually then you can do the Find and Replace in code as well ;)
This would work as Sum and Average have the same structure.
=Sum(<Range>)
=Average(<Range>)

Resources