Excel: Search within column and then search within the respective row - excel

I have a table, let's call it Table 1, with a column identifier, ID, and for each ID (i.e. row) there are various respective dates.
In another sheet, there is a monthly calendar but also with a column having the ID.
I would like to have a function that would first read through the first column to determine which is the proper row from Table 1. After doing this it would check whether in this month there is any corresponding date from Table 1 for this particular ID (i.e. row).
Your help is much appreciated.

For this you can use the index,match,match way.
If you haven't used it yet,I will shortly explain.
The index function works as follows:
=index(A1:E10, 2, 5)
'Returns the value in the second row and the fifth column of the range "A1:E10" so the value of "E2"
The match function works as follows:
=match("Hello",A1:E1, 0)
'returns the index at which it found the value "Hello" e.g C1 has the value "Hello" it will return 3. The third paramter "0" says you want an EXACT match
Lets say your table is in range A1:D10 first row is header and first column IDS.
ID | Value1 | Value2 | Value 3
1 | ....
2 | ....
..
Now you want to find the entry at "Value1" with ID = 3
=index(A1:D10, match("Value1",B1:D1, 0), match(3, A1:A10, 0))

Related

How to count values that exist in other column within a range in Excel?

If I have table 1 with OrderIDs and CallIDs and table 2 with CallIDs (that are referenced in table 1) and callDates, how can I find the number of orders within a given date range?
I believe what I need to do is get the calls that are within a date range in table 2, then check if the CallIDs exist in table 1, then get the count of the result. I just do not know how to put it all together in a formula. For instance in the picture, the number of orders in February should be 3.
=SUM(COUNTIFS(E2:E15,">="&DATE(2022,2,1),E2:E15,"<"&DATE(2022,3,1),D2:D15,B2:B8))
COUNTIFS creates an array of 0's and 1's (respectively FALSE and TRUE) for the date range in column E containing values greater than or equal to February 1st and smaller than March 1st and where the call number from column D is found in column B.
SUM adds up the 1's and 0's resulting in your count of matches in that range.

Auto Increment the value of a cell based on an adjacent sell value plus search last number increment by 1

Ok I have 2 excel columns
1st column A "Workstream", is a data list with three numbers as a dropdown. 1,2,3
2nd column B "ID", would like to auto-populate based on the selection made from the left adjacent cell + perform a lookup to get the MAX number in the current column and ADD by 1.
For Example:
Workstream
ID
1
W1-001
1
W1-002
1
W1-003
1
W1-004
2
W1-001
1
W1-005
2
W1-002
So when a user selects from the drop-down in column A then Column B auto-populates with something like this
="W"&A:1&"-"
However, in order to complete the value, it needs to do the following:
="W"&A:1&"-" Search for the Max Record in Column B that starts with 1 or whatever value was entered into Column A, then include the next number based on the MAX value selected in Column A
So in the above example, let's say I Enter "2" in column A, then the value that auto-populates in column B would be
| 2 | W2-003
or if I selected 1 from column A given where we left off then the value that would auto-populate in column B would be:
| 1 | W1-006
If I am understanding correctly and you want the format to be "W" followed by number of the workstream (as inferred from the text of your question) try:
="W"&A2&"-"&TEXT(COUNTIF(A$2:A2, B2), "000")
If instead you want the output exactly as shown in the picture you provided, it's even easier:
="W1-"&TEXT(COUNTIF(A$2:A2, B2), "000")
EDIT: You might consider pre-dragging the formula to all the rows that you think have the possibility of being impacted so that you don't have to drag the formula each time you add a row. In that case, try:
=IF(A2="","", "W"&A2&"-"&TEXT(COUNTIF(A$2:A2, B2), "000"))

Return cell's value based on its date range in Excel

I have a table with specific products and dates and I want to get the cost values that correspond to that date . The source table has a range of dates and not an actual match (that is my problem).
Here is the task: we are trying to fill column "Cost" based on Sheet 2
SHEET 1:
Product
Date
Cost
price
First
29/12/2021
result 1 (formula type X)
100
Second
05/01/2021
result 2 (formula type X)
200
The other Sheet has the date ranges with the desired results (selling prices), like this:
SHEET 2:
Product
Start Date
End Date
Cost
First
28/12/2020
03/01/2021
result 1
Second
04/01/2021
11/01/2021
result 2
PS. I have different costs for different products in the same date. So, we needed to also add a parameter that will match the Product from one sheet with the product of the other.
If the given Ranges both start at A1 and end at D3 then the following works in Sheet1!C2:
=INDEX(Sheet2!D:D,MATCH(1,(B2>Sheet2!B:B)*(B2<Sheet2!C:C)*(A2=Sheet2!A:A),0))
This is an array formula to be entered with ctrl + shift + enter
It Indexes sheet2 column D and searches for the first match where all mentioned condition are true (=1). Each condition produces 1 or 0 for each cell in the range and multiplies it by the result of the cell from the next range in the same row. If either of the conditions is false it multiplies by 0 resulting in 0.
If all conditions are true it will result in 1 (111).
The overall produces an array of {0,0,1,0,...} and the match function returns the N'th occurance of the first 1, which is equal to the row number of the conditions being true.
Since you mentioned tables I'm going to assume you mean a real Excel Table and not just cells formatted into a table like appearance.
Sheet 1 Table is named: tbl_ProductPrice
Sheet 2 Table is named: tbl_ProductCost
"Cost" column formula in sheet 1:
=SUMIFS(tbl_ProductCost[Cost],[Date],">="&tbl_ProductCost[Start Date],[Date],"<="&tbl_ProductCost[End Date])
Explanation
First SUMIFS parameter, "Cost" column, is what will be summed up if all criteria are true.
First IF:
Second parameter is the date criteria to check.
Third parameter is what to check against, is greater than or equal to start date.
Second IF:
Fourth parameter is the date again for the second if statement
Fifth parameter is checking if less than or equal to the end date.
Results:
EDIT
Based on your comment regarding multiple product entries for different date ranges I would go with the Index Match approach instead.
=INDEX(tbl_ProductCost[Cost],MATCH(1,([#Product]=tbl_ProductCost[Product])*([#Date]>=tbl_ProductCost[Start Date])*([#Date]<=tbl_ProductCost[End Date]),0))
Enter formula with Ctrl+Shift+Entersince it's an array formula.
I added in a product match as well since you indicated multiple date ranges for each product type.
Results

How to VLOOKUP an Excel Table in another Excel sheet

I am trying to VLOOKUP a value in an Excel Table and get the value from another Excel Table in another sheet.
the first table is called PRODUCTS and the second one is called PRODUCT DETAILS
In PRODUCTS I have:
GTIN-13 | SKU | NAME | PRICE
In PRODUCT DETAILS I have:
GTIN-13 | SKU | NAME | GW | NW
From PRODUCT DETAILS I am trying to Vlookup SKU from PRODUCTS and get the GTIN-13 value into PRODUCT DETAILS
GTIN-13 (PRODUCT DETAILS): =VLOOKUP([#SKU],PRODUCTS,1,)
But formula return #N/A.
I can't understand where I am mistaken
In PRODUCTS table, move SKU column to the leftmost of the table. So column order will be as below:
SKU | GTIN-13 | NAME | PRICE
In PRODUCT DETAILS table, use the below formula:
=VLOOKUP([#SKU],PRODUCTS,2,FALSE)
In this VLOOKUP formula, the number 2 indicates that you are trying to fetch the value from 2nd column (i.e. GTIN-13 is the 2nd col in PRODUCTS) when there is a match on SKU in the first column (VLOOKUP always tries to match values in the first column of your search range) in PRODUCTS.
Hope that helps!
VLOOKUP only works when the common column in both the table is on the left side of the desired values column.
You can just change the SKU column position to the left of GTIN-13 column and your formula will work fine.
Now if you don't want to tamper with the data tables and want more powerful lookup function, then you can use INDEX & MATCH functions.
INDEX takes 3 values - INDEX(Table, Row, Column)
MATCH takes 3 values - MATCH(Cell, Column, [-1, 0, 1]) ---- Here 0 is used to find the exact match
Now if you combine the both functions you can replace the Row of INDEX with the MATCH function.
It will be like this - INDEX(Table, MATCH(Cell, Column, 0), Column)
My formula in the sheet is INDEX(I:J, MATCH(D2, J:J, 0), 1)
Here I have used 1 as the Column of INDEX because I wanted the values of GTIN-13.

Excel: Create Custom Sheet 2 Based on Data in Sheet 1

I have two sheets in a spreadsheet. Each sheet has a first column with common values (however they are not sorted the same and they are not all there in each sheet).
What I'm trying to do, if possible, is put a formula in sheet 2, where, if column 1 is a match for sheet 1, copies selective data from certain columns in that same row in sheet 1, to certain columns in sheet 2.
Example:
Sheet 1 has a heading setup and sample data row like this:
Title | Day of Week | First | Last
Supervisor | Wednesday | Mike | Jones
Sheet 2 has a heading setup and sample data row like this:
Title | Surname | Weekday
Supervisor | (empty cell) | (empty cell)
After running the mystery formula I'm looking for, placed in the 2 empty cells above, sheet 2 should match on the Supervisor key in sheet 1 and copy in data I have specified into each column, such as:
Title | Surname | Weekday
Supervisor | Jones | Wednesday
(In this case I have told it to map the "day of week" column to weekday, and map the "last" column to "surname").
I hope this is easy/possible??? Help???
VBA is not necessary. You can use a simple VLOOKUP:
=VLOOKUP(cell to look-up,
range where you want to look up the values (first column *must* contain the keys to look-up) including all columns that you want to retrieve,
the position of the column to be retrieved relative to the first column specified in argument 2,
0 (specifies you want an exact match))
For example:
=VLOOKUP(A1, Sheet1!$A$1:$D$150, 2, 0) ' Retrieves the 2nd column matching criteria in A1
Please notice, however, that you need your keys to be unique. Matching information based on the title seems a bit odd since it is likely there will be more than one person assigned to a certain role. For example, there may be more than 1 supervisor.
Use INDEX and MATCH (better than VLOOKUP).
I suggest renaming your headers so they match on both sheet.
Sheet 1 should be :
Title | Weekday | First Name | Surname
In sheet 2, cell B2 type in
=INDEX(Sheet1!$A:$D,match($A2,Sheet1!$A:$A,0),match(B$2,Sheet1!$1:$1,0))
You can drag and drop it in column C as well, it will work since you are using two MATCH functions with the cells properly anchored.

Resources