IF THEN (sourcing a table on Sheet 2) - excel

I'm looking to create an Excel spreadsheet using what I think is a bit of a complicated IF/THEN. I want to have a table on Sheet 2 that gives a value in one column (e.g., Column A: Between 5 and 5.5), and another value in Column B (e.g., A-).
On Sheet 1, I will have a column (e.g., F) that has the number that should fall somewhere within Column A. I would like to automatically update Column I with the value that is in Column B on Sheet 2.
So I want to have a formula in cells in Column I that looks at the value in Column F (and refers to the relationship between these values in Columns A & B in Sheet 2).
Is this doable?
The table in Sheet 2 would be:
15 | A+
14 | A
13 | A-
12 | B+
11 | B
10 | B-
09 | C+
08 | C
07 | C-
06 | D+
05 | D
04 | D-
03 | E+
02 | E
01 | E-

Using nested IFs is a horrible idea, you should consider using a lookup table instead.

The last parameter of VLOOKUP is probably what you are looking for. Setting it to true makes the function looks for approximate match instead of exact match.
You will need sort your table in ascending order (i.e. from 1(E-) to 15(1+)).

=LOOKUP(F1,Sheet2!A1:A3,Sheet2!B1:B3)
Try this Code put in the Sheet 1. Column I

If you are using Excel 365, you can use the new IFS statement.
=IFS(A1<=1,"E-",A1<=2,"E",A1<=3,"E+",A1<=4,"D-",A1<=5,"D",A1<=6,"D+",A1<=7,"C-",A1<=8,"C",A1<=9,"C+",A1<=10,"B-",A1<=11,"B",A1<=12,"B+",A1<=13,"A-",A1<=14,"A",A1<=15,"A+")
That said, since you already have a table on your second sheet, I would highly recommend using an INDEX/MATCH method as suggested by #Michal Rosa

Related

Excel formula for calculating unique occurrences in a column grouped by another column

I need to build a single Excel formula for calculating the third column in the table below based on the previous two columns.
First column shows the name of the active user
Second column shows which week number the activity occurred
The third column should in every row show the total number of unique
weeks that the user in the first colum has been active ever.
------------------------------------------------
NAME ACTIVE-IN-WEEK-NO NUM-UNIQUE-ACTIVE-WEEKS (Need a formula for this one)
------------------------------------------------
JOHN | 50 | 2
ADAM | 48 | 3
PETER | 48 | 1
JOHN | 50 | 2
JOHN | 50 | 2
ADAM | 45 | 3
ADAM | 40 | 3
PETER | 48 | 1
JOHN | 45 | 2
-------------------------------------------------
For this requirement you need to use Microsoft Query ,
refer the link given below :
http://www.excel-easy.com/examples/microsoft-query.html
To Fix this you need to write sql statement in microsoft query.
Hope this Helps.
Assuming your table is in A1:B10 (with headers in row 1), this array formula in C2:
=SUM(IF(FREQUENCY(IF($A$2:$A$10=A2,$B$2:$B$10),$B$2:$B$10)>0,1))
Copy down as required.
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

How to sum a row in Excel with lookup values from a column based lookup?

I have rows of values in columns AC to AU (but also some blanks)
I want to convert these values in a formula via a lookup and sum all the lookup values in a row.
For 1 cell I can use VLOOKUP(AC2,'Lookup_Table'!A2:B41,2) successfully
How do I sum the whole row of AC2 to AU2 with this kind of lookup?
Note the lookup is column oriented in a vertical lookup, the 'Lookup Table' is actually a worksheet.
This has stumped me for hours now!
| AC | AD | AE ..Ax... AU
Row 1 | 12 | 23 | 43 ..00... 67
'Lookup table' worksheet
A | B
12 | 4
23 | 2
43 | 3
67 | 5
The result should be 14 for the sample Row 1 data above
It is much easier to use an array formula (ctrl+shift+enter instead of just enter). Generally I don't like array formulas (because they are easy for the uneducated to break), but I think it will work the best in your situation apart from reformatting your sheet or using helper columns.
{=SUM(IF(AC2:AU2=Lookup_Table!A2:A41,Lookup_Table!B2:B41))}
which should have {} around the whole thing if you entered it correctly.
You need to use a combination of SUM and INDEX functions, where AB in Lookup_Table is your index column for the table, and A! is the value you wish to lookup:
=SUM(INDEX(Lookup_Table!$AC$1,MATCH(A1,Lookup_Table!$AB:$AB,0)):INDEX(Lookup_Table!$AU$1,MATCH(A1,Lookup_Table!$AB:$AB,0)))

Excel SUMIF column value matches

I would like to sum all values in column J when the value in column K matches. So, for example, I have the following:
COL J | COL K
25.00 | Now
45.00 | Aug 15
40.00 | Sep 10
70.00 | Now
14.00 | Aug 15
92.00 | Now
I'd like Excel to find all matching values in Column K and add up the values in corresponding rows of column J. For the example above it would sum 25.00, 70.00 and 92.00 which correspond with "Now" and then also add up 45.00 and 14.00 which correspond with Aug 15.
I know it can be done with formulas like this:
=SUMIF(K:K,"Now",J:J)
=SUMIF(K:K,"Aug 15",J:J)
However, I'd like to be more flexible and not have to have a separate formula for every different value in Column K. Is there a way to use a wildcard of some sort that can replace "Now" and "Aug 15" in the example above so that I could just have one formula that finds any matches in Column K and sums the corresponding values for those rows in Column J?
Thank you!
SUMIF accepts wildcards (e.g., this or this).
I tried adding another line to your data,
92.00 | Never
and then =SUMIF(K:K,"N*",J:J). It works great. If I understood what you were specifically aiming at, it would be =SUMIF(K:K,"*",J:J).
PS: I wouldn't know how it behaves when you have cells formatted as date, and you try to match according to what is displayed. That might involve locale issues.
You need to investigate Array Formulas also known as CSE formulas. http://www.mrexcel.com/articles/CSE-array-formulas-excel.php or http://office.microsoft.com/en-us/excel-help/guidelines-and-examples-of-array-formulas-HA010342564.aspx
=SUM(IF($K$1:$K$6=K1,$J$1:$J$6,0))
If you paste this formula into cell L1 (assuming your data is in K1:J6) and press Control-Shift-Enter to save it, it will calculate the sum of all the cells in Column J that have a matching Column K. Array Formulas are pretty powerful but they are pretty hard to debug.

Sumif Function involving dates and text

I have a three columns which contain a range of dates, ie 6/15/2013, corresponding items ie. gravel, asphalt etc and corresponding tonnages. I need to be able to sum all of the tonnages of asphalt per month.
I have tried several sumif statements but they are all coming back with no value. Everything was going fine until I tried to add the sorting by month "if" statement.
Any help is appreciated.
Sample Data below
Column A | Column B | Column C
6/23/2013| Asphalt | 12
7/14/2013| Asphalt | 14
6/15/2013| Gravel | 15
8/15/2013| Gravel | 18
6/3/2013 | Asphalt | 14
thanks
If you have Excel 2007 or later try using SUMIFS, e.g. in F2
=SUMIFS(C:C,B:B,"Asphalt",A:A,">="&E2,A:A,"<"&EOMONTH(E2,0)+1)
where column A contains dates, B items and C tonnages....and E2 should contain the 1st of the month for which you want to sum. You can add more more dates in E3 down and then copy that formula down

Find two matching rows and display data from the thirt one (Excel)

So i have Two Sheets.
First sheet contains two columns
BRAND | LEFTOVER
The second sheet consists of two columns also.
BRAND | LEFTOVER (%)
So in case if the BRAND row value in the first Sheet will match the BRAND row value in the second i want to display the matching LEFTOVER (%) row value in the first sheet rows in the column LEFTOVER.
Kind of lost here.
Appreciate any ideas. Thanks.
In Sheet2:
. A | B
--------------------
1 BRAND | LEFTOVER %
2 X | Y
3 |
In Sheet1:
. A | B
--------------------
1 BRAND | LEFTOVER
2 X | =VLOOKUP(A2,Sheet2!A:B,2)
3 |
The VLookup function searches for its first parameter (in this case the value of Sheet1!A2) in the first column of the range denoted by the second parameter (in this case the leftmost column of the range containing columns A and B on Sheet2)
It then returns the value from that same row of the range that is to the right in the columns denoted by the third parameter (1 is the leftmost column where the matched value was). So in this case we use the number 2 because 1 means column A and 2 is column B (which explains why we used a two column wide range for the second parameter - it needed to encompass the column the result was in)
This isn't the only way to do this, but it is the easiest.
As Jerry stated VLOOKUP is the simplest way to do this.
HOWEVER if you have multiple/repeat instances (rows) in BRAND, VLOOKUP will only return the first record (row) that appears in your data.
If this is the case, you will need to add either a unique identifier column; and/or additional criteria to differentiate between the repeat instances.
As an example column A is used as a unique identifier to differentiate between the 2 'Nike' rows.
A B C
1 BRAND LEFTOVER
2 Nike 50
3 Adidas 25
4 Reebok 30
5 Nike 29
I feel that you can use vlookup to accomplish your goals.
Let me explain it in a bit detail.Suppose you have two sheets as:
A | B | A | B
--------------------- | -------------------
1 BRAND | LEFTOVER % | 1 BRAND | LEFTOVER
2 X | Y | 2 X | =Vlookup(A2,Sheet2!A:B,False)
3 | | 3 |
Sheet2 | Sheet1
After this you can drag this formula for the entire range. This will automatically make the formula correct for the below cells as well.
Also, if you need to populate any other fields from the Sheet2 then you can also use the vlookup as an array formula like: VLOOKUP(A2,Sheet2!A:B,{1,2,3,4},FALSE)
Enter this as an array formula using Crtl+Shift+Enter
Here {1,2,3,4} stands for the columns to be fetched.
If you want to know more about vlookup then read this article: http://www.exceltrick.com/formulas_macros/vlookup-in-excel

Resources