Excel SUMPRODUCT and MMULT with condition - excel

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.

Related

How to refer a cell data into countifs formula?

My excel image:
At E6 cell, I used this formula:
=countifs(Example1!$L$19:$L$1000;$B$6;Exampale1!$M$19:$M$1000;$C$6)
And at F6 cell, i used this formula with C8 cell contains the sheetname that I want to refer:
=countifs('INDIRECT(C8)'!$L$19:$L$1000;$B$6;'INDIRECT(C8)'!$M$19:$M$1000;$C$6)
why are there 2 different returned results?
As expected, I want F6 will return as E6.
I tried to search but nothing can resolve.
That's not how indirect works.
Replace the formula in F6 as follow.
=COUNTIFS(INDIRECT("'"&C8&"'!"&"$L$19:$L$1000"),$B$6,INDIRECT("'"&C8&"'!"&"$M$19:$M$1000"),$C$6)

Excel drop down lists and average function

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.

If 1 or 2 cells are blank then

I'm trying to write a simple formula to check whether either 1 or both cells are blank and, if so, leave the resulting cell blank. I want the resulting cell to only display a calculation if both cells are filled in.
I've got this do far though it doesn't work as I wanted: =IF(OR(C4<>"",B4<>""),A4-C4,"")
b4 has a date and c4 has a numeric value (4). the formulate is in d4. I want to check if b4 or c4 are blank and, if so, leave d4 blank too, else take c4 from a4 (14 as of now).
It should work:
=IF(ISBLANK(C4);"";IF(ISBLANK(D4);"";A4-C4))
It checks if C4 is a blank cell, if not then checks if D4 is blank, if not then does the math.
I recommend using ISBLANK to check for blank cells.
Formula for your D4:
=IF(OR(ISBLANK(B4), ISBLANK(C4)),,A4-C4)
Just try this formula
=IF(AND(C4<>"",B4<>""),A4-C4,"")
Also, I used =IF(A2&B2="",TRUE VALUE, FALSE VALUE) which worked great

How to create formula in excel that can iterate in specific range?

I want to fill down 10 cells with value from B10 cell:
='Disconnect Minor Reason List'!$B$10
Then I want to get another 10 cells with value from B11 cell, then another 10 from B12 and so on.
Is it a possible in Excel?
First approach (better one, since it's not volatile):
write formula in E10 cell: =B10
write formula in E11 cell: =INDEX($B$10:$B$12,1+INT(COUNTA($E$10:E10)/10))
and drag it down.
Second approach: (if you'd like to use single formula)
use this formula in E10 and drag it down:
=INDEX($B$10:$B$12,1+INT((ROW()-ROW($E$10))/10))

Excel: Separate text in cell

I am trying to seperate a field into two by finding the values that are in the left of an asterisk and then what's on the right.
For example
Cell C1 is 0A*33 then C2 should be 0A and C3 should be 33.
I have the following formulas in cells C2 and C3:
=LEFT(C1,SEARCH("~*",C1,1)-1)
=RIGHT(C1,LEN(A3)-SEARCH("~*",C1,1))
These formulas work great as long as there is a asterisk in the cell, if not it results in a #VALUE! error.
I have even tried (For the left side) =LEFT(C1,IF(ISERROR(SEARCH("~*",C1,1)-1),C1,SEARCH("~*",C1,1)-1)) with the same outcome.
If the cell does not have an asterisk it must return the whole value in C2 and nothing in cell C3.
Have you tried:
In C2:
=IF(ISERROR(FIND("*",C1)),C1,LEFT(C1,FIND("*",C1)-1))
In C3:
=IF(ISERROR(FIND("*",C1)),"",RIGHT(C1,LEN(C1)-FIND("*",C1)))
You could use the same idea with SEARCH, but FIND works fine in this case:
In C2:
=IF(ISERROR(SEARCH("~*",C1,1)),C1,LEFT(C1,SEARCH("~*",C1,1)-1))
In C3:
=IF(ISERROR(SEARCH("~*",C1,1)),"",RIGHT(C1,LEN(C1)-SEARCH("~*",C1,1)))
=LEFT(C1,FIND("*",C1&"*")-1)
=MID(C1,FIND("*",C1&"*")+1,255)

Resources