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?
Related
Using only "vlookup" does not work because there are a bunch of malfunctioning minutes & total numbers of it. So as I know I should combine "vlookup" with "sum" or I am wrong? please support me on this query.
You can use Countif() to count with conditions and Sumif() to sum up numbers that fulfill a condition.
In cell K10 (count System No malfunctions)
=Countif(A:A,K9)
... in words: count the rows in column A whose text is equal to that in cell K9.
In K11 you can conditionally sum with this formula:
=Sumif(A:A,K9,C:C)
... in words: for all the rows in column A whose text is equal to that in cell K9, sum the values in column C.
Copy the two formulas from K10 and K11, paste them into K15 and K16 and change the reference from A:A to D:D to look at the code column instead of the system number.
I want to match specific rows and columns.
If A2 is matched with B1, then return list "ROW 1" in B2:B151
If A5 is matched with B5 then return list "ROW 4" in B2:B151
As explained in the image B2 is feed by a Dropdown from another sheet (This is not part of the question)
I am trying to override this list in B2:B151 every time a new match is made.
I haven't got a clue on how to proceed have tried multiple Index and match combination even Vlookup which is not viable for this sort of problem.
I was thinking of concatenating all these formulas in B2. The reason why I want to use Rows and columns to determine the specific match is that the data in B1 an A2:A7 is ever-changing and that's the reason why the formula needs to be dynamic.
I think this is what you want, but I'm not 100% sure of the desired final outcome.
The formula in B1 is
=OFFSET($D2,0,MATCH($B$1,PhaseArrayList,0)-1,1,1)
and you can just copy that down as many rows as you need. When you change the value in B1 it will update.
The Offset says says start at D2, go 0 rows down, go to the right the number of columns equal to the match of B1 less 1. So if C is in B1 the match returns 3 and the offset goes across 2 columns, i.e. to column F (ROW 3).
(Btw would be less confusing if you labelled them columns!)
Let’s say I have a column wherein there are blank rows and rows that combine text and numbers. For example, A1 might look like "some text (2)", A2 might contain "some more text (7)", A3 might be blank and A4 look like A1 and A2. I would like to be able to quickly find the sum of the numbers in between the parentheses in column A. I have figured out how to use the MID, LEFT, and FIND functions to extract the values from each string, but getting their sum amounts to an extremely long formula (considering the column might contain as many as twenty such cells). This is what I have been using:
SUM(IFERROR(MID(LEFT(A1,FIND(")",A1)-1),FIND("(",A1)+1,LEN(A1)), 0) +
IFERROR(MID(LEFT(A2,FIND(")",A2)-1),FIND("(",A2)+1,LEN(A2)), 0)+...
And so on, down to the last desired row. This is far too tedious. Is there a shorter way?
You can use an array formula:
=SUM(1*IFERROR(MID(LEFT($A$1:$A$20,
FIND(")",$A$1:$A$20)-1),FIND("(",$A$1:$A$20)+1,LEN($A$1:$A$20)), 0))
Enter using Ctrl+Shift+Enter
E.g:
So this seems like it should be pretty easy. I could just concatenate and make another column in the data to make a unique combo and get my answer. But that just seems so messy. So here I am reaching out to you fine folks to pick your brains.
I want to look up HQLine and Description in the MPCC tab to return the correct MPCC Code. I tried a couple IF statements with VLOOKUPS but couldn't get it right.
So I need to look up BK3 Positive Crankcase Ventilation (PCV) Connector in the MPCC tab. So it needs to match BK3 and the Long description and then give me the correct code.
Here is the missing data file
Here is the MPCC export list that I want to search
Use SUMIFS.
SUMIFS will find the sum in a table of rows that meet certain criteria. If the MPCC is always a number, and the MQAb-LongDescription is always unique, SUMIFS will find the correct ID.
=SUMIFS(Sheet1!C$2:C$100,Sheet1!A$2:A$100,A2,Sheet1!B$2:B$100,B2)
where Sheet1!A$2:A$100 is the HQAb data, Sheet1!B$2:B$100 is the Long Description data, Sheet1!C$2:C$100 is the MPCC Number data, A2 is the HQLine, and B2 is the Description.
The formula would go in C1.
More information on VLookup with Multiple Criteria
You can use an Index/Match with multiple criteria.
I'm assuming that you will put this formula in "Sheet1", cell C2, and your lookup data is in a sheet called "Sheet2", columns A, B, C from row 2 to 30.
Put this in Sheet1, C2:
=INDEX(Sheet2!$C$2:$C$30,MATCH(A2&B2,Sheet2!$A$2:$A$30&Sheet2!$B$2:$B$30,0))
(Enter with CTRL+SHIFT+ENTER) and drag down.)
Adjust the ranges as necessary.
lets assume your first Table is on sheet 1 in the range A1:C11 and the MPCC codes are located on Sheet 2 in the range A1:C32. Each table has a header row so your data really starts in row 2.
Similar to BruceWayne's answer of using an array formula, you can bring the array calculation inside of a formula and avoid the special array treatment. There are a few functions that can do this. I will demonstrate with the SUMPRODUCT function;
On Sheet 1, Cell C2, use the following formula:
=INDEX('Sheet 2'!$C$1:C$32,SUMPRODUCT((A2='Sheet 2'!$A$2:A$32)*(B2='Sheet 2'!$B$2:B$32)*row('Sheet 2'!$A$2:A$32))
Explanation:
When the value in A2 matches the value in the range in the second sheet it will be true and false when it does not. when True False get used in math operations they are treated at 1 and 0 respectively. Therefore the only result from your two search criteria will be the rows where A2 match is true and B2 match is true and this will have a value of 1. The 1 will then be multiplied by the row number. Since all other results will be 0 since your list is a unique combination, the sum part of sumproduct will sum up to the row number where your unique row is located. This in turn is used by the indext function to return the row to give your unique number.
An excel table have two columns of grades. I would like to calculate the average grade but adding only the maximum grade of each row.
It is possible to do this by adding additional column that would contain max of each row and calculating the average of it. I am interested to know if there is a cleaner solution that relies only on formulas.
Let's say in cell A1, you have the heading "first" and in B1 you have "second"
In cells A2 to B4, put in your number grades. Use the following formula in D2.
=AVERAGE(IF(A2:A4>B2:B4,A2:A4,B2:B4))
Hit ctr+shift+enter so that the formula has curly brackets and looks like so
{=AVERAGE(IF(A2:A4>B2:B4,A2:A4,B2:B4))}
This is an array formula and so it's looking at A2, checking if it's higher than B2, if so, it takes A2, otherwise takes B2. It then does this again with A3 and B3 etc and builds up an array of the figures you need to calculate the average (but doesn't show them to you).
The average on the outside is then calculating the average of the numbers in the array.
This assumes your grades are number scores and not letters. Apologies if my assumption is incorrect.
If you want to use the helper column, you could use the formula MAX().
Example: =MAX(A2:B2) would give you the larger of the two. Just copy down the column.
Then you could still use the AVERAGE() function to average the numbers in that column.