Excel Index Matching between Value Range - excel

I have a problem when trying to do index matching. I want to match the item from table 1 and table 2 to obtain the Sample field. If Item from table 1 is matched with table 2 Item and the Lot size from table 1 is in between table 2 LotSizeFrom and LotSizeTo. It will obtain the Sample field from table 2.
table 1
table 2
Expected Output

try the following formula. You will need to sort your data by item ascending and then by lot size from, also ascending. The column Lotsize to is not required. See the screenshot for the cell references.
=INDEX(INDEX($D$1:$D$19,MATCH(H2,$A$1:$A$19,0)):INDEX($D$1:$D$19,MATCH(H2,$A$1:$A$19,1)),MATCH(G2,INDEX($B$1:$B$19,MATCH(H2,$A$1:$A$19,0)):INDEX($B$1:$B$19,MATCH(H2,$A$1:$A$19,1)),1))

INDEX() combined with SUMPRODUCT() should work :
=INDEX($I$2:$I$18,SUMPRODUCT(ROW($F$2:$F$18)-1,($F$2:$F$18=B7)*(A7>=$G$2:$G$18)*(A7<$H$2:$H$18)))

Related

Excel lookup if matching key and another value in the same row is greater than 1

I have a list of keys that I want to return another key if another column matches that key and is greater than one. Then it will return the key if that same other column is equal to 1. I will attempt to explain this better with visuals below. I would appreciate any assistance or at least how I would go about doing this.
What I am Starting With:
What I would like to end with:
Use INDEX/AGGREGATE:
=IFERROR(INDEX($B:$B,AGGREGATE(15,7,ROW($A$2:$A$9)/($A$2:$A$9=$E2),COLUMN(A1))),"")
Put that in the first cell and copy over as far as desired and down the unique list:
If one has Office 365 Excel then put this in the first cell and drag down the unique list and it will spill to the right as needed:
=TRANSPOSE(FILTER(B:B,A:A=E2,""))
You can use a pivot table and put Key1 in the rows and Key 2 in the columns. Then you can drag the Quantity fields into the filter and make sure you only get the columns = 1.
Finally, if you want to initial Key for the quantity that is > 1 you could either use a second pivot or you order die initial table descending by quantity and use index match or vlookup to return the first match (which if ordered correctly will be the key for the quantity > 1).

Lookup based on two criteria including between ranges fields

I'm trying to do a Lookup formula to get get the exact value based on two fields against 3 fields (two of the lookup fields are Min and Max fields) so the idea is to get the value based on field name and another numeric field against two fields because it is a range of numbers
Lookup Table
Table where formula will be created (Inside LookupResult). See below the expected result where Price 150 for 101-A-A should be ABCD
Thanks for the help
You just need some indexing, no need for MATCH nor VLOOKUP. For example:
Formula in H2:
=INDEX(D:D,MAX(INDEX((A$2:A$3=F2)*(B$2:B$3<=G2)*(C$2:C$3>=G2)*ROW(A$2:A$3),)))
Or, if rules can really only apply to a single row:
=INDEX(D:D,SUMPRODUCT((A$2:A$3=F2)*(B$2:B$3<=G2)*(C$2:C$3>=G2)*ROW(A$2:A$3)))

Calculated Fields in excel pivot

I have column ('CSAT') in a sheet that has numbers 1 and 0 in each cell. '1' represents 'Satisfied' and '0' represents 'Disatisfied'. I want to make a pivot from this sheet and have a new calculated field in it ('CSAT %') that will give me the score by dividing (Total 'Satisfied') count by (Total 'Dissatisfied + Total 'Satisfied') * 100.
I tried with COUNTIF but i dont think we can use this formula in pivot
Calculated Fields and Items in PivotTables are tricky. The main tripping point is understanding that Calculated Fields and Items operate on the totals, not on the individual values in the underlying data.
For example, if you created a new Field that was equal to Field1 * Field2 and data is being summarized by SUM, Excel doesn't multiply all of the respective values in each field and then sum the results. It first sums the fields for each category and then multiplies those results. What it's really doing is SUM(Field1) * SUM(Field2) for each category.
You can use some worksheet functions in the calculated fields, but you have to remember you're still operating on the totals. So if you created a new Field that was equal to Count(Field1) * Count(Field2), you're (almost) always just going to get an answer of 1. This is because the calculation is actually doing Count(SUM(Field1)) * Count(SUM(Field2)) for each category. The sum of each field is a single number, so the calculation is just doing 1*1 for each category.
So for this reason, you can't use aggregating functions like SUMIF or COUNTIF which need to look at each individual elements. Since you need to look at individual elements, you actually can't use a Calculated Field for your solution at all.
What you can do is use a Calculated Item!
The main catch here is you can't use any field in more than 1 location when calculated items are involved. Excel just throws an error message saying you're not allowed.
So if you have a category column as well as the CSAT column, you need to create another dummy column full of 1's to operate on.
You can then set up pivot table as follows:
Category field to Rows.
Dummy field to Data area, summarized by Sum
CSAT field to Columns
Click on the CSAT column headers in the pivot table and choose: PivotTable Tools > Fields, Items, & Sets > Calculated Item
Set Name for your new Item to CSAT%
Enter the formula: ='1'/('0'+'1')
On the CSAT field, hide items 1 and 0, so only the CSAT% field is visible
Result:
A couple of notes:
When entering fields and items in calculated fields and items, do so by placing the cursor where you want in the Formula then double clicking on the field/item name from the lists below. This will add brackets and quotes as required in the correct format.
Note that the formula doesn't need SUM around the item names, because calculated fields/items always work on the total of values. They are totalled according to how the data is summarized in the pivot table.
The dummy column was added with all values of 1 so that summing these values gives you the count, from which the percentage can be calculated using the formula specified.
Answer without using calculated fields:
Assuming you have categories in the row fields, you can put CSAT as a column field as well as a data field then choose to summarize values by Count and show values as a percentage of row totals:
After putting CSAT in column and data fields, right click on the data and select Summarize Values By > More Options...
First choose to Summarize Values By Count:
Then click Show Values As tab and select % of Row Total:
You'll then have percentage of 1's under the CSAT=1 column:

Reference an Index for current status

I am trying to figure out how to have Excel take a column of text from one table and reference another table as an index of what value to enter back into the first table. Example:
Table 1:
Greg__Blue__5
Cindy_Green_3
Table 2:
Green__ 3
Blue____5
I want to populate the third column with the number that lives in Table 2. So that I will have table two act more like an index as data changed in Table 1.
Maybe:
=VLOOKUP([#Colour],Table2[#All],2,0)

Using ROW() with structured referencing to return list of selected records by criteria

My task is to return a list of items from the records in one table (with structured referencing), from another table (with structured referencing), if the record in the first table "KitList" has a quantity of 1 or greater.
Currently my closest result is using the following formula
=INDEX(KitList[Item],SMALL(IF(KitList[Quantity]>0,ROW(KitList[Quantity])),ROW(1:1)))
However, this returns incorrect values. Specifically, it returns the row after the row containing 1 (or greater), and skips the first row. i.e.
KitList
[Item]|[Quantity]
Item a | 1
Item b | 0
Item c | 2
Item d | 1
Item e | 0
Return
Item b
Item d
Item e
I think this is due to some interaction of the ROW commands counting the headers of the tables, as well as the data in them, therefore reading the range as a whole with the header, and giving an extra row in the return value. Is there a way, in the final ROW command to specify the row I need through structured referencing? Would that fix the problem?
The ROW function will return the row in the spreadsheet, not the row of the structured data. Easy solution ROW - 1
EDIT: My original answer didn't produce the desired result when copied down.
I think this is what you want:
=INDEX(KitList[Item],SMALL(IF(KitList[Quantity]>0,ROW(KitList[Quantity])-ROW(KitList[#Headers])),ROW(1:1)))
This will also allow you to move the source Table anywhere you want, i.e. the header row doesn't have to be 1:1, and the results can also be located anywhere as well.
{=INDEX(KitList[[#All],[Item]],SMALL(IF(KitList[Quantity]>0,ROW(KitList[Quantity])),ROW(1:1)))}
By specifing to the index that I want to include 'all' of the kit list table, the data and the header, not just the header, I've managed to fix the problem. Still seems awkward though.

Resources