VLOOKUP if only a part of the search criteria matches with the values in the table - excel

I have the following Excel spreadsheet:
A B C
1 List Search Criteria Result
2 2019-01 9 2019-09
3 2019-02
4 2019-03
5 2019-04
6 2019-05
7 2019-06
8 2019-07
9 2019-08
10 2019-09
11 2019-12
12
In Column A I have a list of all months in 2019. In Cell B2 I want to search for a month by just enterring in the number of the month. The result should appear in Cell C2. Therefore, I tried to go with the following formula in Cell C2:
C2 =VLOOKUP(B2,$A$2:$A$13,1,FALSE)
The issue is now that basically my search criteria is not 2019-09. It is just 9 and therefore the VLOOKUP is not able to find it within Column A.
So far I came up with the following solutions to solve this issue:
a) Change the search criteria to ="2019-"&B2.
b) Add a helper column next to Column A in which I only dsiplay the number of the months
However, I am wondering if there is smarter solution which does the job within the VLOOKUP function directly (maybe a combination with the MID function)?

Based on the comments below the question there are two solutions to solve the problem:
Option A)
If the year in the list does not change and will be the same you can go with this formula:
=VLOOKUP(TEXT(B2,"\*00"),$A$2:$A$13,1,FALSE)
Option B)
If the year in the list changes you can go with this formula and edit the first parameter accordingly:
=VLOOKUP("2019-"&TEXT(B2,"00"),$A$2:$A$13,1,FALSE)

Related

Subtotals in a column based on ranges in another column

Consider a table like the following:
WEEKNUM HOURS WEEKTOTAL
==============================
1 2
1 4 6
2 3
2 5
2 1 9
3 6 6
... ... ...
I am searching for a formula to use in the WEEKTOTAL column that sums those entries in the HOURS column that share the same weeknumber. I would like the actual subtotal entry to be added in the row that contains the last occurrence of each weeknumber (the entries are likely sorted by weeknumber). The other cells in this column can be empty.
I'm hoping this is possible using an ARRAYFORMULA, but I am not sure how to.
Thank you in advance!
Assuming "WEEKTOTAL" cell is C1.
in C2 :
=IF(A2<>A3,SUM(OFFSET(B2,0,0,-1*COUNTIF(A:A,A2))),"")
and drag downwards.
Idea : use countif() to 'drive' offset() range. Which in turn will be the range for sum(). All only happens if the next column a value is different (IF(A2<>A3, .. ) ).
Pls share if it works/not/understandable.

Find element in a matrix in excel [duplicate]

I have the following Excel spreadsheet:
A B C D E F
1 MFC2 MFC1 QFC Search Criteria: CW14
2 CW11 Column Name: MFC1
3 CW13
4 CW14
5 CW17
6 CW18
7 CW19
8
9
In Cells A1:C8 I have different calender weeks. All of them are unique!
In Cell E2 I want that the column name is displayed based on the value that is put in Cell E1.
In this case the search criteria is CW14 so the result should be column name MFC1.
I tried to modify the formula from this question but could not make it work:
E1 = INDEX($A$1:$C$1,MATCH(E$1,$A$2:$C$30,0))
This formula gives me #NV as result.
What do I need to change to get the desried result?
Use AGGREGATE instead of MATCH:
=INDEX(1:1,AGGREGATE(15,7,COLUMN($A$2:$C$30)/($A$2:$C$30=$E$1),1))
=INDEX($A$1:$C$1,MAX(ISNUMBER(FIND(E1,$A$2:$C$7))*COLUMN($A$2:$C$7)))

Find column name based on search criteria

I have the following Excel spreadsheet:
A B C D E F
1 MFC2 MFC1 QFC Search Criteria: CW14
2 CW11 Column Name: MFC1
3 CW13
4 CW14
5 CW17
6 CW18
7 CW19
8
9
In Cells A1:C8 I have different calender weeks. All of them are unique!
In Cell E2 I want that the column name is displayed based on the value that is put in Cell E1.
In this case the search criteria is CW14 so the result should be column name MFC1.
I tried to modify the formula from this question but could not make it work:
E1 = INDEX($A$1:$C$1,MATCH(E$1,$A$2:$C$30,0))
This formula gives me #NV as result.
What do I need to change to get the desried result?
Use AGGREGATE instead of MATCH:
=INDEX(1:1,AGGREGATE(15,7,COLUMN($A$2:$C$30)/($A$2:$C$30=$E$1),1))
=INDEX($A$1:$C$1,MAX(ISNUMBER(FIND(E1,$A$2:$C$7))*COLUMN($A$2:$C$7)))

VLOOKUP with multiple criterias in different columns [duplicate]

This question already has answers here:
Vlookup using 2 columns to reference another
(2 answers)
Closed 3 years ago.
I have the following Excel spreadsheet:
A B C D E
1 Products Brands Revenue Search Criterias
2 Product A Brand1 500 Criteria 1: Product C
3 Product B Brand3 800 Criteria 2: Brand 3
4 Product B Brand2 900 Revenue: 300
5 Product C Brand1 200
6 Product C Brand3 300
7 Product C Brand4 750
8 Product D Brand1 450
9 Product C Brand4 150
10
As you can see in Column A I have list of products and in Column B the corresponding brands and in Column C the revenue.
Now I want to use VLOOKUP to search for the revenue based on a product (Cell E2) and a brand (Cell E3). Therefore, I tried to go with this formula:
E4 =VLOOKUP(E2&"-"&E3,A1:C9,3,FALSE)
However, this formula gives me #NV.
What do I need to change in my formula to make it work?
Please note:
I know I could solve this issue by adding a helper column in which I combine the datas from Column A and Column B and then let the VLOOKUP run over this helper column. However, I am looking for a solution without this helper column.
First of all, please note that your lookup array does not have a space while your lookup value does! That will never return a match, so address that issue first.
Furthermore, I would highly recommend to not concatenate values in a multi-criteria lookup, ever! That's very error prone. Instead use boolean logic to create an array of 1's and 0's to use the powerfull combination of INDEX and MATCH. Try to get into the habit of using that combination over VLOOKUP if you are a regular user of Excel and it's worksheet functions.
Here is a small introduction to this combination of functions. And as mentioned in that post too, INDEX will come in handy much more often as you will notice in the below example when we create our return array. This will prevent the use of having to enter as an array formula through CtrlShiftEnter =)
Formula in E4:
=INDEX(C2:C9,MATCH(1,INDEX((A2:A9=E2)*(B2:B9=E3),),0))
When you actually got numeric values under Revenue you can simply use SUMIFS, as the other answer suggest.
I would strongly recommend using SUMIFS instead of VLOOKUP because this would make sure if you have multiple same values it will add them together:
=SUMIFS(C:C,A:A,E2,B:B,E3)
But this function will only work in newer versions of Excel if you need it for an older version of excel you need to work with SUMPRODUCT
Optional you can also use an alternative VLOOKUP which would be a combination of INDEX and MATCH. There are two options, either the array formula with the "{}" can in some cases result to wrong data, but is easy to understand:
{=INDEX(C:C,MATCH(E2&E3,A:A&B:B,0))}
This is a matricial formula so the "{}" are added by Excel when you type the formula regularly by pressing CTRL + SHIFT + ENTER
otherwise use. I would always recomend using regular formulas over matricial formulas
Quote user JvdV
Formula in E4:
=INDEX(C2:C9,MATCH(1,INDEX((A2:A9=E2)*(B2:B9=E3),),0))
The shortest and fastest formula for 2 criteria Lookup is using DGET()
Table layout as below :
A B C D E F
1 Products Brands Revenue Search Criterias
2 Product A Brand1 500 Products Brands Revenue
3 Product B Brand3 800 Product C Brand3
4 Product B Brand2 900
5 Product C Brand1 200
6 Product C Brand3 300
7 Product C Brand4 750
8 Product D Brand1 450
9 Product C Brand4 150
Formula in F3 :
=DGET(A1:C9,F2,D2:E3)
and, will return the desired result : 300

I WANT CALCULATE SUM IN EXCEL

I HAVE A QUESTION ABOUT SUM IN EXCEL:
I have many rows in excel.
I want to calculate sum of each row in one formula
for example
A B C D E
2 3 5 6 8 24
4 5 6 8 9 32
BUT do not USE separate formula FOR EVER CALCULATION (FOR EXAMPLE =sum A1:D1)
CAN I USE WITH ONE FORMULA TO CALCULATE SUM OF EVERY ROWS
You do not have to manually enter the formula to calculate sum of every row.
In the first row you would input =SUM(A1:D1) (did you mean to include E1 as well?)
Then follow the instructions here to apply it the other rows

Resources