Vlookup this text string - excel

I would like to know how to go about this. Imagine a text string such as this
/search/p300_action/search?catid=1&makeid=0&modelid=0&locid=1&yearmin=min&yearmax=max&pricemin=min&pricemax=max&conid=0&displaylocal=1&searchtext=Enter+Keyword(s)+/+AutoID
and I want to break down the info into respective categories such as makeid, modelid, yearmax etc... and relate the relevant categories into another page that have values for it. E.g lets say makeid: 0, 1, 2, 3 .... stands for makename: HP, samsung, compaq, acer respectively.
Kindly give me a simplified way to go about this.

I'm not at all clear what you require (and I'm not alone!) but maybe Text To Columns (Delimited and Other: & as delimiter) then something like =VLOOKUP(VALUE(RIGHT(B1,1)),Sheet2!A:B,2,FALSE)

Related

Parse a string into a Table using FILTERXML

This is related this question. The OP proposed to give inputs to a formula that contain a list of connection quantities and speeds like this:
1x1000,2x200,1x50 would mean that there is one 1000k connection, two 200k and 1 50k. I would like to parse this into an array table like this:
1
1000
2
200
1
50
I tried this formula, but it only produces the left hand side of the table:
=LET( case, A5,
a, FILTERXML("<t><s>"&SUBSTITUTE(case,",","</s><s>")&"</s></t>","//s[contains(., 'x')]"),
FILTERXML("<t><s>"&SUBSTITUTE(a,"x","</s><s>")&"</s></t>","//s") )
where case is the input variable, a parses the table into strings containing "x" (this is to ensure that only valid "q x speed" strings are used. I then tried to split this array and... no joy.
From this post by JvdV, I think the answer can be found in the xpath, but I cannot find a solution.
Looks like you want to either spill the entire array or use it in later calculations? Either way, I came up with:
=LET(X,FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(A1,",","x"),"x","</s><s>")&"</s></t>","//s"),INDEX(X,SEQUENCE(COUNT(X)/2,2)))
Or, a littel more verbose without LET():
=INDEX(FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(A1,",","x"),"x","</s><s>")&"</s></t>","//s"),SEQUENCE(LEN(A1)-LEN(SUBSTITUTE(A1,"x","")),2))
One way to get it is something like
=LET(x, FILTERXML("<t><s>"&SUBSTITUTE($A$1, ",", "</s><s>")&"</s></t>", "//s"),
IF(SEQUENCE(1,2)=1, LEFT(x, SEARCH("x",x)-1), RIGHT(x, LEN(x)-SEARCH("x",x))))
Once you break up the string by comma, you can then break up the component strings by "x" with something like
=TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(A7, "x", "</s><s>")&"</s></t>", "//s"))
but I'm not sure if you can combine the two actions in one go to get both width and depth dimensions (i.e. =TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(original_filterxml, "x", "</s><s>")&"</s></t>", "//s")) will not work).
Maybe,
In C1, formula copied right to D1 and all copied down :
=TRIM(MID(SUBSTITUTE(SUBSTITUTE(","&$A$1,"X",","),",",REPT(" ",99)),((ROW(A1)*2+COLUMN(A1))-2)*99,99))
Or,
If using FILTERXML function, try :
=IFERROR(FILTERXML("<a><b>"&SUBSTITUTE(SUBSTITUTE($A$1,"X",","),",","</b><b>")&"</b></a>","//b["&(ROW(A1)*2+COLUMN(A1))-2&"]"),"")

How to extract text from a string between where there are multiple entires that meet the criteria and return all values

This is an exmaple of the string, and it can be longer
1160752 Meranji Oil Sats -Mt(MA) (000600007056 0001), PE:Toolachee Gas Sats -Mt(MA) (000600007070 0003)GL: Contract Services (510000), COT: Network (N), CO: OM-A00009.0723,Oil Sats -Mt(MA) (000600007053 0003)
The result needs to be column1 600007056 column2 600007070 column3 600007053
I am working in Spotfire and creating calclated columns through transformations as I need the columns to join to other data sets
I have tried the below, but it is only picking up the 1st 600.. number not the others, and there can be an undefined amount of those.
Account is the column with the string
Mid([Account],
Find("(000",[Account]) + Len("(000"),
Find("0001)",[Account]) - Find("(000",[Account]) - Len("(000"))
Thank you!
Assuming my guess is correct, and the pattern to look for is:
9 numbers, starting with 6, preceded by 1 opening parenthesis and 3 zeros, followed by a space, 4 numbers and a closing parenthesis
you can grab individual occurrences by:
column1: RXExtract([Amount],'(?<=\\(000)6\\d{8}(?=\\s\\d{4}\\))',1)
column2: RXExtract([Amount],'(?<=\\(000)6\\d{8}(?=\\s\\d{4}\\))',2)
etc.
The tricky bit is to find how many columns to define, as you say there can be many. One way to know would be to first calculate a max number of occurrences like this:
maxn: Max((Len([Amount]) - Len(RXReplace([Amount],'(?<=\\(000)6\\d{8}(?=\\s\\d{4}\\))','','g'))) / 9)
still assuming the number of digits in each column to extract is 9. This compares the length of the original [Amount] to the one with the extracted patterns replaced by an empty string, divided by 9.
Then you know you can define up to maxn columns, the extra ones for the rows with fewer instances will be empty.
Note that Spotfire always wants two back-slash for escaping (I had to add more to the editor to make it render correctly, I hope I have not missed any).

Spreading out column cells into 3 columns in sets of 2-3?

I understand the question is confusing, so I got a self explanatory picture for you.
I've got a long column with repeating cells in sets of 3, rarely 2. To be precise, it's in the format of A-1, A-2, A-3, B-1, B-2, B-3, and so on.
The part after the hyphen is always the same, but the part before varies.
A and B will each have 3 elements, then C will look like C-1, C-2 with no C-3.
It doesn't happen often in the column but it does sometimes.
Now I have to take all 3 elements of A and spread them into 3 separate columns just like in the picture. Is this doable in sheets/excel?
GS:
=ARRAYFORMULA(IFNA(VLOOKUP({FILTER(A2:A, REGEXMATCH(A2:A, "-1$")),
FILTER(REGEXEXTRACT(A2:A, "(.+-)")&2, REGEXMATCH(A2:A, "-1$")),
FILTER(REGEXEXTRACT(A2:A, "(.+-)")&3, REGEXMATCH(A2:A, "-1$"))}, A2:A, 1, 0)))
Here is a version Excel Office365 version. It lists out all the .pdf options in the header since it looks like you have alternate spellings in the file names.
=LET(input,A2:A1000,
data,FILTER(input,(input<>"")*(RIGHT(input,4)=".pdf")),
rightPartDash,IF(ISERROR(FIND("-",data)),data, RIGHT(data,LEN(data) - FIND("|",SUBSTITUTE(data,"-","|",LEN(data)-LEN(SUBSTITUTE(data,"-","")))))),
rightPartSpace,IF(ISERROR(FIND(" ",data)),data, RIGHT(data,LEN(data) - FIND("|",SUBSTITUTE(data," ","|",LEN(data)-LEN(SUBSTITUTE(data," ","")))))),
rightpart,IF(LEN(rightPartSpace)>LEN(rightPartDash),rightPartDash,rightPartSpace),
leftPart,LEFT(data,LEN(data)-LEN(rightpart)),
leftList,UNIQUE(leftPart),
rightList,TRANSPOSE(UNIQUE(rightpart)),
searchFor,leftList&rightList,
output, XLOOKUP(searchFor,data,data,""),
i, SEQUENCE(ROWS(leftList)+1,1,0),
j, SEQUENCE(1,COLUMNS(rightList)),
IF(i = 0,rightList,INDEX(output,i,j)))

Excel: Formula to combine potentially incomplete address components into an address string with appropriate separators

I need to intake U.S. address data by street, city, state, and ZIP code and output an address in the following format:
1502 Bruce Rd, Oreland, PA 19075
without any superfluous spaces.
Any component of the address can be missing, so each of the four elements binarily exists or doesn't, which results in a total of 4! = 24 permutations of having or not having each of the four elements. Excluding the case where they're all missing, that leaves 23 permutations to deal with.
There seem to be lots of questions about splitting addresses apart, but none about combining them back together, especially when you need to either include or exclude the spacing based on what comes after. What's the best way to handle this? Bonus points for a way that's easily extensible (for example, I won't be surprised if later we have to include a unit field between street and city at some point in the future).
As I was writing up this question, I came up with a couple solutions, where columns A, B, C, and D are street, city, state, and ZIP code, respectively.
First is this one:
=TRIM(
IF(A1="", "", A1 & IF(B1&C1&D1="", "", ", ")) &
IF(B1="", "", B1 & IF( C1&D1="", "", ", ")) &
IF(C1="", "", C1 & IF( D1="", "", " " )) &
IF(D1="", "", D1)
)
which works as follows:
See if the element exists and, if so, include it.
If the element exists, see if anything exists after it and, if so, add the spacer that follows it. (This works because spacers seem be determined by what is before the spacer.)
And the whole thing's wrapped in a TRIM to get rid of unnecessary user-input spaces.
To check if anything after an element exists, I concatenated the following fields and checked to see whether that concatenation was a blank string.
Because of the use of concatenation here, I thought it might be easier to use TEXTJOIN and came up with this:
=TEXTJOIN(" ", TRUE, TEXTJOIN(", ", TRUE, TRIM(A1), TRIM(B1), TRIM(C1)), TRIM(D1))
which works as follows:
The inner TEXTJOIN combines the first three elements (street, city, and state) with the common delimiter of a comma + a space.
Once that's done, the outer TEXTJOIN combines the result of that with the ZIP code using a space as a delimiter.
TRIM used again as above.
These seem to cover all 23 cases and aren't too hard to extend if additional fields need to be added, although I'm definitely open to any better solutions you might have.

Highlight Excel Cells Related to Two Different Multiple Values

Have a problem to solve. I am creating a file with category ID’s (numeric) and have different specification fields for each category, some of them are the same some are changing depending on category ID.
Let's say:
I have category ID’s for cell A2 (cat id: 111), A3 (cat id: 222), A4 - (cat id: 333) and so on.
Category “111” contain specifications like: Price; Condition; Size; Colour; Brand.
Category “222” contain specifications like: Price; Condition; Brand; Manufacture; Shape; Model.
Category “333” ………
My list looks like that:
A1-Cat ID B1-Price C1-Cond. D1-Size E1-Colour F1-Brand G1-Colour H1-Manufacture I1-Shape J- Model
A2-111
A3-222
A4-333
As you can see I have a list of specifications and different category ID’s related to a particular specification.
My question is: how can I highlight cells of each specification which is related only to particular ID. I have about 40 specifications and 15 different ID’s so it is frustrating every time scroll through the rows, remember ID that you work with and follow separate specifications sheet related to ID’s? Specifications must stay in a list all the time, leave empty cell if doesn’t match with ID.
Not sure if this is the best way so if any of you guys have other options to consider, please let me know.
Thank a lot for any answer and help.

Resources