EXCEL: Reordering a list of items according to another list containing keywords - excel

On Excel, I have a list of items on column A that's ordered, and a list of corresponding items on column B that's unordered. Column A's items each contain a keyword that's to be matched to their corresponding item in column B. How do I reorder column B's items so that they match the order in column A?
My current data:
Column A
Column B
Table
3_Chair
Chair
2_Eraser
Pen
4_Table
Eraser
1_Pen
Desired output:
Column A
Column B
Table
4_Table
Chair
3_Chair
Pen
1_Pen
Eraser
2_Eraser

With ms365, try:
Formula in D1:
=LET(x,A1:A4,y,B1:B4,HSTACK(x,XLOOKUP("*_"&x,y,y,,2)))

You can simply sort that second column, but you need to select it first (don't select the title), like in this simple example (also mind the choice I made in the question):
Result:

This will work also with Excel 365
=INDEX(B2:B5,MATCH(A2:A5,TEXTAFTER(B2:B5,"_"),0))
If Excel 365 is not on current channel, TEXTAFTER has to be replaced by MID

Related

EXCEL - Find if value exists in column B in the range of a value in column A

I have a list of companies with certain products. Now I want to find out if one company has a certain product or not. Example, I want to find out which company had Product C and return a one on all cells:
Column 1
Company A
Company A
Company A
Company A
Company B
Company B
Column 2
Product A
Product B
Product C
Product A
Product B
Column 3 (Result):
1
1
1
0
0
This solution will require 2 additional columns. I'm assuming your first row is headers, and the range is from A1:B6. Data starts on Row 2. I'll give a few options on how to execute this though. Where I put "Product C" can also reference a cell. Whenever I'm using binary like this it's usually to filter datasets, so there might be a better alternative to what you want vs. what's below.
In Column C, =if(B2="Product C",1,0) or you can use =--(B2="Product C")
Sort by Column C in Descending Order, =vlookup(A2,$A$2:$A$6,1,0) copy and paste as values, but if you keep the formula and resort it will mess up.
If Product C would only appear once for any given company you can us Sumifs too. =Sumifs($C$2:$C$6,$A$2:A$6$,A2)
If you have 365, you can also use Maxifs($C$2:$C$6,$A$2:A$6$,A2), which won't care how you sort the dataset.

group the results of a matching function

i have three columns in excel, one that holds the row id, the next one a product serial number, and the last one again some serial numbers.
098 11079851 11079851
110 11089385 25853201
118 11089385 22412115
798 11079851 22412115
what i need to do, is to find if the value in column B, exists in column C. Then, i need to have a way, to have the values of column B, that were found in column C, grouped, along with their corresponding row ids.
example output of 11079851 that exists in column C:
11079851: 098, 798 perhaps one cell had the row id, and the next ones, each one having a corresponding number from column B, that may be found in column C.
in excel this is what i use so as to get the existance of each cell's value of column B in column C:
=NOT(ISERROR(MATCH(B2,$C$2:$C$1000,0)))
since i do not have excel version required (even 2016 will not have textjoin), i tried the suggested formula from below answer,
=IF(COUNTIF($C$1:$C$4,B1),B1&": "&TEXTJOIN(",",TRUE,IF($B$1:$B$4=B1,$A$1:$A$4,""))"")
but i get a 509 error. What am i missing?
Maybe in D1:
=IF(COUNTIF($C$1:$C$4,B1),B1&": "&TEXTJOIN(",",TRUE,IF($B$1:$B$4=B1,$A$1:$A$4,"")),"")
Enter through CtrlShiftEnter
Drag down...
Note that this would work in Excel2016 or later with TEXTJOIN() enabled.
P.S. I don't have TEXTJOIN() myself and can't test if this works for you.

if 2 cells match, return the value on another spreadsheet

Here's an example table:
'Sheet one'
Column A: Name of Fruits
Column B: Quantity Ordered
Column C: Price
'Sheet two'
Column A: Name of Fruits
Column B: Quantity Ordered
How do I return the price value that matches from Sheet1 Column C to Sheet2 Column C (new column)?
I am following this formula but it doesn't provide me the correct matching price:
=INDEX('Sheet one'!B:B, MATCH('Sheet two'!C2, A:A,0))
Your lookup key consists of two columns. You have two options:
create a helper column where you concatenate the two column values, then use that for the lookup
dynamically combine the lookup value and lookup columns. This will be slow if you use whole columns, so keep it to only the rows with data.
=index(Sheet1!C1:C10,match(Sheet2!A1&Sheet2!B1,index(Sheet1!A1:A10&Sheet1!B1:B10,0),0))
If I'm reading your formula correctly, it looks like your index is returning Column B, which is quantity ordered.
=INDEX(*column to return*)MATCH(*value to check*, *column to search for value*, *search type*))
You can see 6 different possibilities HERE (and below) depending on what you're trying to do. Copy the sheet to make edits.
Standard
Index/Match:=INDEX(Sheet1!$C$2:$C,MATCH(A3,Sheet1!$A$2:$A,FALSE))
Google Sheets Query (1 Column Return/1 Match Key):
=QUERY(Sheet1!$A$2:$D,"Select C where A='"&D3&"'",0)
Index/Match/Multiply:=INDEX(Sheet1!$C$2:$C,MATCH(A3,Sheet1!$A$2:$A,FALSE))*H3
Google Sheets Query (2 Column Return/1 Match Key): =QUERY(Sheet1!$A$2:$D,"Select B, C where A='"&K3&"'",0)
Index/Match with Multiple Match Keys:
=ARRAYFORMULA(INDEX(Sheet1!$C$2:$C,MATCH(1,(O3=Sheet1!$A$2:$A)*(P3=Sheet1!$B$2:$B),0)))
See HERE for use with Excel.
Google Sheets Query (1 Column Return/2 Match Keys): =QUERY(Sheet1!$A$2:$D,"Select C where A='"&S3&"' and B like '"&T3&"' ",0)
If my answer or teylyn's worked, please check the green check mark to accept the answer.

Fill in table based a column of categories in Excel

I have a table that looks like this:
Type Value
Movie 5
Food 3
Gas 10
Food 2
.... ....
And There's a second table I want to fill in with "Value" based on their type in the first table, so that the corresponding rows look like this:
Rent Food Movie Gas Clothing ... ( appear in specific order bc they are subcategories)
5
3
10
2
The title row is already there, so I was thinking there might be some kind of lookup method to do this? How do I do that?
your second table apperas to hold one value per row but it doesn't have a label. it does correlate to the original row number, is this by design or coincidence?
if this is by design then you can use those 2 columns, hide them if you like, get a unique list of categories by copying you r abels to a new colum, removing duplicates in the data tab, then paste special transpose in c1 to create colum headers.
so column a and b remain unchanged
row 1 contains header starting at column c
your data starts at c2
this is the formula
=Iferror(vlookup(C$1,$A2:$B2,2,false),"")
drag it down and to the right
you can copy paste special values when done to remove the formulas
for something with only a hundred or thousand cells this will be one of the easier options but i would not do this on large tables, for those i would use power query or VBA
Assuming your 1st table is in Sheet1 and 2nd table is in sheet2.. you may try to fill in Sheet2!A2
=IF(Sheet1!$A2=A$1,Sheet1!$B2,"")
and drag it all the way.. Hope you get how it works.. and what you need.

How to sort a column (with additional columns) to match another column in Excel 2010?

How do I sort multiple records (rows) in Excel to match a specified order by providing a column that it should match?
So lets say for example I have records in a worksheet as below:
Name Age Sex
Tom 20 M
Andrew 30 M
Mike 33 M
And I want to sort the records looking at the first column (Name). Not alphabetically but by any order I prefer. For example I want to sort it so that the first column matches this order so I provide a separate column as:
Andrew
Mike
Tom
So in this case I want the entire record set (name, age, sex) to be moved around to match this order. So final should output should look like:
Name Age Sex
Andrew 30 M
Mike 33 M
Tom 20 M
Trying to do this in Excel 2010, so I'll have both the table data and match column in the same worksheet. How can I do this?
Thanks
In your data sample, the desired sort order is alphabetical by first name, for which you can just use the built-in sort functionality.
If you want a custom sort order, create a custom list, as pointed out by pnuts in the comment. Click File > Options > Advanced > find the button Edit Custom Lists and create a custom list.
Alternatively, create a helper table. Put the names in the first column, in the desired order. In the next column number the cells from 1 to the end, so now the sort order number is in that column. Add a lookup column to your data table and perform a =vlookup(name,HelperTable,2,0), copy down, then sort the table by that helper column.

Resources