Excel drop down lists and average function - excel

Currently, I have a formula that helps me calculate an average depending on two drop down lists. I managed it so that the average is calculated even when any one of the drop down lists are empty.
Screen capture of current two-drop-down arrangement:
I would now like to do the same thing but this time have an average function that works with 3 drop down lists: I want it to return the value that corresponds when 1, 2 or 3 of the drop down cells are selected.
I somehow get lost when writing the formula and it returns an error. I feel that I am not considering all the possibilities.
Can you help me out?
Thank you :)

Assuming you're wanting to add in the names criteria from your picture, I came up with the following formula. It's pretty long and there may be a cleaner way, but seems to work.
`=IFERROR(IF(AND(A5<>"",B5="",C5=""),AVERAGEIF(Name,A5,Number),
IF(AND(A5="",B5<>"",C5=""),AVERAGEIF(size,B5,Number),
IF(AND(A5="",B5="",C5<>""),AVERAGEIF(color,C5,Number),
IF(AND(A5<>"",B5<>"",C5=""),AVERAGEIFS(Number,Name,A5,size,B5),
IF(AND(A5<>"",B5="",C5<>""),AVERAGEIFS(Number,Name,A5,color,C5),
IF(AND(A5="",B5<>"",C5<>""),AVERAGEIFS(Number,size,B5,color,C5),
AVERAGEIFS(Number,Name,A5,size,B5,color,C5))))))),
"No Combo")`

You have four conditions that can be met and error control for when mismatched conditions produce no results.
A5, B5 and C5 can all have values.
Neither A5, B5 nor C5 have values.
Two of the A5:C5 cells can have values.
A5 is blank
B5 is blank
C5 is blank
One of the A5:C5 cells can have values.
A5 has a value
B5 has a value
C5 has a value
Any combination of A5, B5 and C5 (including blank) produces no matching numbers from D9:D14 resulting in a #DIV/0! error from the AVERAGEIFS function.
The standard formula in D5 is,
=IFERROR(IF(COUNTA(A5:C5)=3, AVERAGEIFS(D9:D14, A9:A14, A5, B9:B14, B5, C9:C14, C5),
IF(COUNTA(A5:C5)=0, AVERAGE(D9:D14),
IF(COUNTA(A5:C5)=2, IF(A5="", AVERAGEIFS(D9:D14, B9:B14, B5, C9:C14, C5),
IF(B5="", AVERAGEIFS(D9:D14, A9:A14, A5, C9:C14, C5),
AVERAGEIFS(D9:D14, A9:A14, A5, B9:B14, B5))),
IF(COUNTA(A5:C5)=1, IF(A5<>"", AVERAGEIFS(D9:D14, A9:A14, A5),
IF(B5<>"", AVERAGEIFS(D9:D14, B9:B14, B5),
AVERAGEIFS(D9:D14, C9:C14, C5))))))),
"nothing to avg")
You may elect to keep the linefeeds and extra spacing in the formula. There are not detrimental and help to organize the formula visually.
      
I've only used the AVERAGE and AVERAGEIFS functions for simplicity. The AVERAGEIF function is just an AVERAGEIFS with only one criteria but it has its parameters flipped around to compensate for the option that the average_range may not be the same range as the criteria_range. With AVERAGEIFS, a separate average_range and criteria_range is not optional. Using only AVERAGEIFS when criteria was involved means that you can use one syntax.
This is a bit more complex than your original which only allowed for a single criteria. With more criteria comes the increased likelihood for more DIV/0! errors. To limit the choices based on other choices, see Conditional Data Validation based on Dropdown List Response for ideas.

Related

How to reference an entire column from one cell in a spreadsheet function

I am looking for a way to accomplish the following using spreadsheet formulae: the output in cell D5 should be the array from cell B5 to the last populated cell (assume the range is contiguous). Thus if text were typed into cell B10, the output would automatically expand.
However, I want to avoid the volatile OFFSET and INDIRECT functions.
So I have this formula in cell D5:
=UPPER(B5:INDEX(B:B,ROW(B5)+COUNTA(B5:INDEX(B:B,ROWS(B:B),,1))-1))
but this is unsatisfactory as it references the B:B column.
In effect I want a construction that returns me B:B given the cell B5 ie the equivalent of =INDIRECT("C" & COLUMN(B5),"FALSE"), but in a non-volatile format.
Any suggestions?
NB. I don't have the very latest Excel. I have LET, SEQUENCE, FILTER etc, but not LAMBDA and the functions that came with it (ie I can't do recursive LAMBDA calls).
Make column B data into a table
the content of cell D5 can then be dragged to a different location, without the formula results changing.

Excel formula to Sum 12 rows every 3 rows

I need to make a sum of 12 rows every 3 rows in excel. That is, I need to sum first from C4 to C15, then from C7 to C18, and so on.
You can use OFFSET function for this, also volatile, but shorter!
Assuming first formula in E2 copied down
=SUM(OFFSET(C$4,(ROWS(E$2:E2)-1)*3,0,12))
I prefer this because it explicitly contains all the required information
C4 = first cell to sum,
E2 = first cell with formula,
3 = row increment,
12 = number of cells to sum
The above gives you the sums on successive rows from E2 (or any other chosen cell) down. If you actually want the sum to be shown every 3 cells e.g. on the first row for each sum then that's simpler - try this formula in D4 copied down
=IF(MOD(ROWS(E$2:E2),3)=1,SUM(C4:C15),"")
.......or even easier.....just put this formula in D4
=SUM(C4:C15)
....leave D5 and D6 blank, then select the range D4:D6 and drag down
You can also use the non-volatile INDEX function
=SUM(INDEX(C:C,ROWS($1:1)*3+1):INDEX(C:C,ROWS($1:1)*3+12))
This works because INDEX returns a reference so you can use the normal Ref1:Ref2 notation for a range.
=SUM(INDIRECT("C"&ROW(1:1)*3+1&":C"&ROW(1:1)*3+12))
Be warned that INDIRECT() is a volatile formula... This means that any change made anywhere in the workbook this formula will recalculate and can cause performance issues.

Excel SUMPRODUCT and MMULT with condition

Hello I need to make a sumproduct with general conditions.
The correct values is shown in cell B6, B7 and B8
In cell B6 I have this formula =A1*A2+B1*B2+C1*C2 to understand what is the result that I expected.
In B7 is =D1*D2+E1*E2 and so on...
I've tried with this formula =SUMPRODUCT(A3:G3=A6,A1:G1,A2:G2) in cell B6 but the result is 0.
Use =SUMPRODUCT(1*(A3:G3=A6),A1:G1,A2:G2) in cell B6.
Better still use =SUMPRODUCT(1*(A$3:G$3=A6),A$1:G$1,A$2:G$2)
and you will be able to copy the formula from B6 to B7:B8 and it will behave as you want.
From this page, I learned that "--" can transform True and False values into 1's and 0's.
That's probably why you are getting 0, the formula you use adds boolean values to numerical values.
So the formula you are looking for in cell B6 is =SUMPRODUCT(--(A3:G3=A6),A1:G1,A2:G2).
Tested on Excel 2010, it worked.

IF statement in Excel - How to give value to 2 or more cells

If I have a IF statement in one of my cells, for example (this didn't work):
=IF(B6="A10VG 125/32",D4="2.67" & C6="125.0","N/A")
Q: How would I make D4 hold the value "2.67" and the cell C6 hold the value "125.0", IF B6 is equal to "A10VG 125/32"
So if one cell holds a certain condition how can I give different values to a number of different cells?
Excel functions exist to determine the value of the given cell only. Input in, output out. You will need a separate function for each cell.
Excel formulas in a cell can NOT change the values of other cells.
If you want to use formulas, then you will need to put the appropriate formula into the respective cells.
In this scenario, in D4 use the formula
=IF(B6="A10VG 125/32","2.67","N/A")
In C6 use the formula
=IF(B6="A10VG 125/32","125.0","N/A")

Sum cells factored according to criteria

When a cell in A2:A100 meets a certain condition, I want to multiply a corresponding value by a factor and, for a different condition, the corresponding value by a different factor, eg when A2=:
"Banana" then B2*C2 but when
"Apple" then B2*C3 but when
"Pear" then B2*C4
and sum these results, all in a single cell.
So when A2="Banana" and A3="Pear" I want to have this: =B2*C2+B3*C4.
The corresponding values for the criteria in ColumnA are in ColumnB (matching row) and C2, C3 and C4 contain the factors appropriate to the criteria.
I have tried a big formula, but that took me like forever, and when I enter more values in ColumnA I have to adjust that formula.
Please try:
=SUMIF(A:A,"Apple",B:B)*C3+SUMIF(A:A,"Banana",B:B)*C2+SUMIF(A:A,"Pear",B:B)*C4
oops - but with semicolons instead of commas!
=IF(A2="banana";B2*C2;IF(A2="apple";B2*C3;B2*C4))
or do you need something simular but for 100+ cases?

Resources