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

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.

Related

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

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

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.

Sumproduct using 2 criterias and on filtered values

I have the following source table
Date | fruit | veg
The user has previously filtered the date by month. In another table, I want to count the number of apples and tomatoes for example. To remove the invisible rows I use the SUBTOTAL function as
=(SUBTOTAL(102;OFFSET(limiter;ROW(limiter)-MIN(ROW(limiter));;1;1)))
where 'limiter' is the date range.
Then to count the number of apples in the fruit column , I use
= SUMPRODUCT(SUBTOTAL(102;OFFSET(limiter;ROW(limiter)-MIN(ROW(limiter));;1;1)) * Table!fruit = "apple"
and it works fine.
But, if I want to add in the vegetables criteria along with the fruit, the result is 0. I tried doing the sumproduct of fruit and veg first and then add the subtotal function but it gave a huge number.
Have you considered using a pivot table? (I strongly recommend you to)
Go to a new tab, select A1 and insert, new pivot table. You can put the fruit field in the column (probably row labels - my excel is in Portuguese =/). You would instantly have a table containing as first colum the list of existing fruits.
Then add the date to the body (probably values) of the pivot table and certify the type of value shown is count.
You would intantly get the count of all fruits.
The great advantage is that you can play around with this table as easily as dragging and dropping fields in columns, rows and body/values and instantly getting the results you want without having to figure out any formula issues.
Pivot tables also allow you to filter not only the date, but any other fields you wish.

Need assistance with Excel 2010 filtered cells query

I am trying to create a summary sheet that details the amount of a certain product number found in a separate tab. The inventory tab has around 50k records that are filtered by certain manager names.
I need to search by the first four numbers on the inventory tab to match column A on the summary sheet.
Example: The summary sheet may list the model type as 1234, but the inventory sheet lists it as 123463AW3234.
| Model | Codename | Marketing | Quantity |
|-------|----------|-----------|----------|
| 1234  | CN 1     | MN 1    | 1        |
| 1234  | CN 1     | MN 1      | 12       |
| 1234  | CN 1     | MN 1      | 13       |
I would add a formula into column D cells (quantity) that takes the text from cells within column A (model type) searches that through the inventory tab, and lists the quantity of that model type.
This is the formula I have so far, but it detects all cells with 1234 anywhere in the test. I need to edit it where it will only search for the first four numbers taken from column A.
=SUMPRODUCT(SUBTOTAL(103,OFFSET('Development-Asset list'!G2:G33080,ROW('Development-Asset list'!G2:G33080)-MIN(ROW('Development-Asset list'!G2:G33080)),,1)),ISNUMBER(SEARCH(B5,'Development-Asset list'!G2:G33080))+0)
Column G is a seperate tab and contains the full 10 digit product number. I want to pull the data from the model cell (A1) and use it to count the number of products in the sep tab G row.
These rows are filtered which is why I am using SUMPRODUCT. So column G has product numbers like 1234abcde and I want to pull data from A1 (1234) and search column G for matches, but only the first four characters.
Any help would be appreciated!
How about:
=SumIfS(ColumnToSum, ColumnToSearch, Left(A2,4))
Check out the Sumifs function that allows you to set multiple search criteria. Notice that the item I searched for in the third argument is the left 4 characters of the search cell.
how about a simple solution like this:
=SUMIF($G$2:$G$999;A2&"*";$H$2:$H$999)
it sums up the data in column H, if G starts with the four digits of A.

Excel counting pairs

I have 5000 rows. In column A I have the salesperson , in column B the buyer. I am trying to find out how many times each combination appear together. e.g. Did salesman Abe sell to Buyer Bob 33 times, to buyer Carl 19?
ok takes a few extra columns to accomplish this but here goes...screenshot attached first.
First you need to concatenate the two columns (A and B)you want to enumerate in column C (the formula will accommodate a string in case names column is first last with spaces etc.)
=$A2&" "&$B2
Then in column D use the following formula to determine whether or not the name combination is duplicated but only true for one instance. I'll explain why in a second.
=$C1<>$C2
Then in column E count the matches.
=COUNTIF($C:$C,$C2)
After doing all that, filter results by "True" tally for all the True columns is the number of matching rep/customer relationships.

Resources