Excel multiple row to multiple column transformation - excel

I have a spreadsheet with over 6500 rows displaying a list of chemicals and their relationships in the following format:
Chemical | 1,1,2-Trichloro-1,2,2-trifluoroethane :- {FREON TC} | FREON TC
Chemical | 1,1,2-Trichloro-1,2,2-trifluoroethane :- {FREON TC} | ug/l
Chemical | 1,1,2-Trichloro-1,2,2-trifluoroethane :- {FREON TC} | mg/l
I want to transform this all into one row e.g.
Chemical | 1,1,2-Trichloro-1,2,2-trifluoroethane :- {FREON TC} | FREON TC | ug/l | mg/l
This is just an extract of this spreadsheet and there are many chemicals. Any advice much appreciated. This is an exported spreadsheet from an Access database so if there is an Access query that can help I'm all ears.

Have found an answer using power query in Excel, required only some minor changes (delimiter character) but worked perfectly:
https://www.mrexcel.com/forum/power-bi/1063813-convert-2nd-column-values-rows-when-column-1-same-name.html

Related

Comparing two cells and show both of them when it is not equal

I have a table in EXCEL that looks like this:
ATTRIBUTE_IN_1|TYPE_IN_1|ATTRIBUTE_IN_2 |TYPE_IN_2 |
________________________________________________________
advance |String | accounts |decimal(20,10) |
education |String | Job_category |String |
date of birth |date | advance |decimal(20,10) |
and etc.
I want to compare TYPE_IN_1 and TYPE_IN_2 (2nd and 4th columns) for equal values in ATTRIBUTE_IN_1 and ATTRIBUTE_IN_2 (1st and 3rd columns).
In the result I want to see values, when ATTRIBUTE_IN_1 and ATTRIBUTE_IN_2 have equal value, but TYPE_IN_1 and TYPE_IN_2 (2nd and 4th columns) have unequal values.
For that example in result I want to see:
ATTRIBUTE_IN_1|TYPE_IN_1|ATTRIBUTE_IN_2 |TYPE_IN_2 |
_______________________________________________________
advance |String | advance |decimal(20,10) |
What formula can i use in MS EXCEL for solving this problem?
Excel doesn't really lend itself to this type of question. You can cobble something together, perhaps along these lines (for attribute 1):
=IFERROR(INDEX($A$2:$A$10,INT(SMALL(IF(($A$2:$A$10=TRANSPOSE($C$2:$C$10))*($B$2:$B$10<>TRANSPOSE($D$2:$D$10)),
ROWS($A$2:$A$10)*(ROW($A$2:$A$10)-ROW($A$2))+TRANSPOSE(ROW($A$2:$A$10)-ROW($A$2))),ROW(1:1))/ROWS($A$2:$A$10))+1),"")
This sets up a 2D array where the rows are the attribute 1's and the columns are the attribute 2's. The array elements where there is a conflict are set to 1. The rest of the formula is to get the corresponding values out in row/column order.
For type 1:
=IFERROR(INDEX($B$2:$B$10,INT(SMALL(IF(($A$2:$A$10=TRANSPOSE($C$2:$C$10))*($B$2:$B$10<>TRANSPOSE($D$2:$D$10)),
ROWS($A$2:$A$10)*(ROW($A$2:$A$10)-ROW($A$2))+TRANSPOSE(ROW($A$2:$A$10)-ROW($A$2))),ROW(1:1))/ROWS($A$2:$A$10))+1),"")
For type 2:
=IFERROR(INDEX($D$2:$D$10,MOD(SMALL(IF(($A$2:$A$10=TRANSPOSE($C$2:$C$10))*($B$2:$B$10<>TRANSPOSE($D$2:$D$10)),
ROWS($A$2:$A$10)*(ROW($A$2:$A$10)-ROW($A$2))+TRANSPOSE(ROW($A$2:$A$10)-ROW($A$2))),ROW(1:1)),ROWS($A$2:$A$10))+1),"")
It's interesting to compare this with the SQL for doing the same thing e.g. in SQLite:
.mode csv
.import book2.csv test1
select a.attribute_in_1,a.type_in_1,b.type_in_2
from
test1 a inner join test1 b
on a.attribute_in_1=b.attribute_in_2 and a.type_in_1<>b.type_in_2;

How to check data from two worksheets in Excel 2016?

I have raw data from an Excel Query that gives me details for Account Numbers(Field 2). I also have a list of Account Numbers that I want to EXCLUDE from the raw data.
Initially, I thought I could exclude them in SQL with the NOT IN condition. But I was then told that there are about 20,000 Accounts to Exclude.
So, I thought, I could export the raw data to Excel in one Worksheet and Add the Account Numbers to exclude in another worksheet and then have Excel check for those Account Numbers and give a Comment.
Worksheet 1 (Raw Data):
---------------------------------
|Field 1|Field 2|Field 3|Field 4|
---------------------------------
| 1234| A1234B| XYZ| 258.00|
---------------------------------
| 2678| B1234C| ABC| 457.25|
---------------------------------
| 5465| C1234D| DEF| 652.47|
---------------------------------
| 4587| D1234E| GHI| 458.36|
---------------------------------
| 3589| E1234F| JKL| 685.47|
---------------------------------
Worksheet 2 (Accounts to Exclude):
---------
|Field 2|
---------
| A1234B|
---------
| J1234L|
---------
| K1234Z|
---------
| D1234E|
---------
| L1234M|
---------
Intended Result:
------------------------------------------
|Field 1|Field 2|Field 3|Field 4|Result |
------------------------------------------
| 1234| A1234B| XYZ| 258.00|Excluded|
------------------------------------------
| 2678| B1234C| ABC| 457.25| |
------------------------------------------
| 5465| C1234D| DEF| 652.47| |
------------------------------------------
| 4587| D1234E| GHI| 458.36|Excluded|
------------------------------------------
| 3589| E1234F| JKL| 685.47| |
------------------------------------------
Initially, I started by sorting the Account Numbers on both worksheets and then ran the formula:
=IFERROR(VLOOKUP(B2,ExcludedAccounts,2,FALSE), "Excluded")
But then I realised, I am only looking for exact match for each cell. That won't be right.
Question:
What is the Formula to check two columns from different worksheets for similarities across the whole column?
Once I have the flag "Excluded" in another column then I can highlight cell with Conditional Formatting and then segregate those accounts.
Not enough rep to post a comment. The OPs formula is fine, if the "ExcludedRange" covers two columns (as he is returning what is in the second column) with the second column containing only blank spaces.
I'm not sure though what is meant by the below - could you please explain what the similarities are...
...different worksheets for similarities across the whole column
This is another way of doing it with a single column for the excludedrange
=IF(ISERROR(VLOOKUP(A2,ExcludedAccounts,1,0)),"Excluded","")
I think the formula you're actually looking for is
=IF(ISNUMBER(MATCH(B2,ExcludedAccounts,0)),"Excluded","")
When I used your formula, all I received were "Excluded" answers for everything because it was returning an error (this was possibly caused by missing information in your question, but I don't know). EDIT: As stated in the other answer that was submitted, yes, the original formula was looking to return a value from a second column, which would mean that ExcludedAccounts covers a minimum of two columns, not the assumed one.
There are several ways you can handle your request. However, what my above formula does is look for an exact match of the value in B2 against those values in the ExcludedAccounts named range (which I assumed is Sheet2!A2:A6). If MATCH finds one, a number will be returned (this number represents the row within ExcludedAccounts where the value from B2 was found). By wrapping this in the ISNUMBER function and placing it inside an IF statement, we're asking Excel to give us the result of "Excluded" if the excluded account is found on the list, and a result of "" if it isn't on the ExcludedAccounts list.

Excel: Create new Row for each column

I have a data set as follows:
A | B | C |...
1abc | 1def | 1ghi |...
2abc | 2def | 2ghi |...
...
This is a collection of memo notes for each account in our database. The 1 in "1abc" represents the account ID and the letters represent some text. There are a total of 177 columns and 1866 rows but not every row has values up to column 177, some may only have two columns worth of data.
I need each column to drop down to the bottom of column A so that all data only occupies Column A. For example, all the data in column B would inserted after the last value in A. Data in column C would be inserted after the last value in column A after it's been populated with the data from B and so on.
In the end, it should look something like this (from which point I can simply sort it in ascending order).
A | B | C |
1abc | | |
2abc | | |
...
1def | | |
2def | | |
...
1ghi | | |
2ghi | | |
...
Can anyone help out with this? I am assuming that I need a macro and have tried working with the solution found in this post but couldn't figure it out. Oh, and I'm using Excel 2003 if that helps.
I am not sure if this will help but, from what you have given me, it sounds like you have 3 columns of data that you would like to be put into one column. If I am correct in my thinking, you can do this a few different ways. So as to preserve the original document in its entirety while adding an extended sorting system you could: 1: Create new tab. Then highlight range a with your mouse. Using your mouse right click and select copy (try to keep in mind the value of the range, E.g. How many items have you copied. Paste it in your now tab. Do this for the remaining ranges. Or maybe use V look up. If you would like I have a schedule module I have created that has many different types of range associations. You can also split sting in excel to divide the id from the sting.
Without VBA, add a blank row at the top and a column on the left populated throughout with say x and then follow the steps detailed here. Then delete the left-hand two columns and filter the remaining one to remove any blanks.

Match text from column within a certain cell - Excel

I have a column of few thousand filenames that are not uniform. For instance:
| Column A | Column B |
===============================
| junk_City1_abunc | City1 |
-------------------------------
| nunk_City1_blahb | City1 |
-------------------------------
| small=City2_jdjf | City2 |
-------------------------------
| mozrmcity3_somet | City3 |
I would like to identify the city within the text in column A and return it in Column B.
I've come up with a complex formula that does the trick, but it is difficult to adjust if more cities are added within the filenames in new entries within column A.
Here is an example:
=IF(ISNA(MATCH("*"&$W$3&"*",I248,0)),IF(ISNA(MATCH("*"&$W$4&"*",I248,0)),IF(ISNA(MATCH("*"&$W$5&"*",I248,0)),IF(ISNA(MATCH("*"&$W$6&"*",I248,0)),IF(ISNA(MATCH("*"&$W$7&"*",I248,0)),IF(ISNA(MATCH("*"&$W$8&"*",I248,0)),"Austin","Orlando"),"Las Vegas"),"Chicago"),"Boston"),"Las Angeles"),"National")
It seems like there should be an easier way to do it, but I just can't figure it out.
(To make matters worse, not only am I identifying a city within the filename, I'm looking for other attributes to populate other columns)
Can anyone help?
Use the formula =IFERROR(LOOKUP(1E+100,SEARCH($E$2:$E$11,A2),$E$2:$E$11),A2)
This does *****NOT***** have to be array entered.
Where $E$2:$E$11 is the list of names you want returned and A2 is the cell to test
If no matches are found instead of errors you will just use the full name in column b.
If you want errors or expect to NEVER have then you can just use:
=LOOKUP(1E+100,SEARCH($E$2:$E$11,A2),$E$2:$E$11)
Here's a round about way that works, not all my own work but a mish mash of bits from other sources:
Assuming the sheet is setup as follows:
The formula to use is below, this must be entered using Ctrl+Shift+Enter
=INDEX($C$2:$C$8,MAX(IF(ISERROR(SEARCH($C$2:$C$8,A2)),-1,1)*(ROW($C$2:$C$8)-ROW($C$2)+1)))
Annotated version:
=INDEX([List of search terms],MAX(IF(ISERROR(SEARCH([List of search terms],[Cell to search])),-1,1)*(ROW([List of search terms])-ROW([Cell containing first search term])+1)))

Excel if statement with multiple if statements

Help!
I enjoy Excel but I wanted to see if this were an option. I might even consider coding this in a simple javascript or so file.
I am trying to make a code that can be copied and dragged down on each new file that is made from our server.
On the file, there are NPA's and NXX's. If you aren't sure what that is, it is the area code and prefix. Like 555-111-2222. 555 is the NPA and the 111 is the NXX.
Well, I would like to create an IF statement that capture the various NPA and NXXs combinations and what their carrier is for our markets.
For example, 479-203 is Centurylink. However, 479 is in column N and 203 is in column O.
While I can create, if N2 = "479" and O2 = "203", CenturyLink, --- do another if statement.
I was not sure since I have another excel document that does not change with the values present if I could use that to help answer the question.
In columns A and B on another document have the NPA and NXXs. In the same file, column L has the carrier name.
Is there a search capability that I can use for this? If you name the function, I'll look it up too. I'm not picky. :)
Edit:
=IF(OR(N10="479",N10="870"),VLOOKUP(CONCATENATE(N10,"-",O10),[TnList.xls]AR!$A:$D,4,FALSE),VLOOKUP(CONCATENATE(N10,"-",O10),[TnList.xls]KS!$A:$D,4,FALSE))
You will need to add another column to the left of the data in your carrier spreadsheet and fill it with =CONCATENATE(B2,"-",C2) first:
CarrierSpreadsheet.xls:
NPA-NXX | NPA | NXX | Carrier
429-203 | 429 | 203 | CentryLink
123-111 | 123 | 111 | CarrierA
456-222 | 456 | 222 | CarrierB
789-333 | 789 | 333 | CarrierC
Then add 2 columns to your phone number data determine the carrier from your phone number spreadsheet. Column B needs to be filled with =LEFT(C2,7) and column A needs to be filled with =VLOOKUP(B2,[CarrierSpreadsheet.xls]Sheet1!$A:$D,4,FALSE):
PhoneNumbers.xls
Carrier | NPA-NXX | Number
CentryLink | 429-203 | 429-203-9999
CentryLink | 429-203 | 429-203-8888
CarrierB | 456-222 | 456-222-9999
CarrierC | 789-333 | 789-333-9999
Let me know if you have any questions.
PS - If this answer works for you please click the grey checkmark to the upper left corner or my answer.
You can use a LOOKUP formula which avoids adding extra columns, e.g.
=LOOKUP(2,1/(Data!A$2:A$100=N2)/(Data!B$2:B$100=O2),Data!L$2:L$100)
That assumes Data worksheet is your "other file"
You could name the columns; then the formula can simply refer to the names. But you'd have to name the relevant columns in each document; I'm not sure how well that would work for you.

Resources