I have a listing of products that include sizes, in a variety of formats.
I need to separate them into 2 columns, 1 with the sizes, the other with the names.
So, for example, "12"x10" Large Widget" becomes [12" x 10"] [Large Widget].
I'm trying to use REGEXREPLACE to remove the numbers, but can't seem to find a combined syntax that will handle "any number, double quotes, the letter X lowercase and capital" in a single expression.
And then I'd need to do the reverse, in other words, extract JUST the numbers and double quotes and X/x, for the other column.
Can't just use SPLIT or RIGHT/LEFT, because the position of the intended split will differ from line to line. Can't "Split Text To Columns", because there are occasional double quotes in the item names too.
So I'm thinking, Step 1: filter out just the numbers and double quotes, Step 2: filter out just the names.
In other words:
Input: [14" x 17" Large Widget]
Output (2 columns): [14" x 17"] [Large Widget]
Input: [7"x2" Small Gadget]
Output (2 columns): [7"x2"] [Small Gadget]
I understand how REGEXREPLACE works, just need help with the syntax.
Thanks in advance!
try:
=ARRAYFORMULA(IFNA(REGEXEXTRACT(A1:A, "(.+"") (.+)")))
Related
Matlab has limitations in terms of how things can be numbered/indexed:
Arrays and cell arrays require indices that are natural
numbers (with exceptions that are discouraged and not more general).
Field names of structure arrays can only be strings that start with a letter and are followed by letters/digits/underscores.
However, it might be common/appropriate/intuitive to number certain things using zero or negative numbers or non-integer numbers.
For example, storing more and more so-called spherical harmonics requires increasingly negative "indices".
Scaling and shifting those "indices" such that they are natural numbers, i.e. valid (cell-)array indices, has disadvantages (smaller negative indices or finer non-integer indices might appear later, requiring a recomputation of the scale or shift parameters and adjustment of the entire data structure; understanding the resulting data structure requires knowing the scale and shift parameters and requires "mental math" while looking at the data).
Is there a way without these disadvantages?
Numbers can be turned into valid field names for structure arrays for example using this function:
% Field names of Matlab structures:
% - can't start with a digit, so we prepend 'number_',
% - can't contain '-', so we replace it by 'minus',
% - can't contain '+', so we replace it by 'plus' (for numbers such as -1e+20),
% - can't contain '.', so we replace it by 'point'.
% For example, the number -0.5 turns into the string 'number_minus0point5'.
num2fieldname = #(x)(['number_' replace(replace(replace(num2str(x),'-','minus'),'.','point'),'+','plus')]);
For example, num2fieldname(-1.5e+20) yields 'number_minus1point5eplus20'.
To use them as field names, here for example using the "index" (2,-1):
mystructure.(num2fieldname(2)).(num2fieldname(-1)) = myobject
It won't work if rounding settings for num2str change.
In recent versions of MATLAB, the table data type allows arbitrary text as variable names.
containers.Map might achieve what you want. Apparently it can store any objects as values. That seems to be undocumented.
I have a list of name that are on one sheet and need to find the most common repeat name of that list. The list spans for the entire month. Example:
10/1 James
10/2 Bill
10/3 Fred
10/4 Hank
etc...
On another sheet I have this in-cell array that finds the most common, BUT if the list has blanks, it returns an error. Only when the list is full does it then give you an answer.
{=INDEX('Sept 18'!B$2:B$151,MODE(MATCH('Sept 18'!B$2:B$151,'Sept 18'!B$2:B$151,0)+{0,0})),"")}
Is there a way to make it always show a name and exclude the blanks as it goes?
If there is data in B2 through B11 that may include blanks, then use the array formula:
=INDEX(B2:B21,MODE(IF(B2:B21<>"",MATCH(B2:B21,B2:B21,0))))
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
I have been looking around for a while but unable to find an answer to my question.
In Excel, what compact formula can I use to create an array made up of a single element repeated n times, where n is an input (potentially hard-coded)?
For example, something that would look like this (the formula below does not work but gives an idea of what I am looking for):
{={"Constant"}*3}
Note: I am not looking for a VBA-based solution.
EDIT Reading #AxelRichter answer, I see I should also indicate that the formulas below assume Constant is a number. If Constant is text, then this solution will not work.
Volatile:
=ROW(INDIRECT("1:" & Repts))/ROW(INDIRECT("1" & ":" & Repts)) * Constant
non-Volatile:
=ROW(INDEX($1:$65535,1,1):INDEX($1:$65535,Repts,1))/ROW(INDEX($1:$65535,1,1):INDEX($1:$65535,Repts,1))*Constant
If
Constant = 14
Repts = 3
then
Result = {14;14;14}
The first part of the formulas create an array of 1's repeated Repts times. Then we multiply that array by Constant to get the desired result.
And after reading #MacroMarc's comment, the following non-volatile formula shouyld also work for numbers:
=(ROW($A$1:INDEX($A:$A,Repts))>0)*Constant
One could concatenate 1:n empty cells to the "Constant" to create a string array having n items "Constant":
"Constant"&INDEX(XFD:XFD,1):INDEX(XFD:XFD,3)
There 3 is n.
Used in Formula
=INDEX("Constant"&INDEX(XFD:XFD,1):INDEX(XFD:XFD,3),0)
Evaluate Formula shows that it works:
Here column XFD is used because in most cases this column will be empty and a column which is guaranteed to be empty is needed for this solution.
If used
"Constant"&T(ROW($A$1:INDEX($A:$A,3)))
=INDEX("Constant"&T(ROW($A$1:INDEX($A:$A,3))),0)
the need of an empty column disappears. The function ROW returns numbers but the T returns an empty string if its parameter is not text. So empty strings will be concatenated for each 1:3 (n).
Thanks to #MacroMarc for the hint.
Try:
REPT("Constant", SEQUENCE(3,1,1,0))
Or, if the reference is to a dynamic array:
REPT("Constant", SEQUENCE(A1#,1,1,0))
The dynamic array spills, and has your constant repeated one time.
Using SEQUENCE with a step of 0 is a much cleaner way to make an array of constants. You can choose whether you want rows or columns (or both!) as well.
=SEQUENCE(Repts,1,Constant,0)
I will generally use a sequence (like Claire (above) said). But if you want to provide an output of text objects, I would do it this way:
=IF(SEQUENCE(A1,A2,1,0),A3)
Where:
A1 has the number of rows
A2 has the number of columns
A3 has the thing you want repeated into an array
The sequence will create a matrix of 1's, which the IF statement will default to the TRUE expression (being the contents of A3).
So, if you wanted a vertical list of 3 items that says "Constant", this would do it:
=IF(SEQUENCE(3,,1,0),"Constant")
If you would prefer it be arranged horizontally instead of vertically, just amend the SEQUENCE function:
=IF(SEQUENCE(,3,1,0),"Constant")
=SUM(SUMIFS('Output'!$H$50:$H$69,'Output'!$C$50:$C$69,{"*PLoan","Deficit Loan"},'Output'!$G$50:$G$69,X97:AC97))
I have the above array formula. X97:AC97 is where I have my array literal and the values in this array literal are conditioned on some other parameters (let's say the values are a,b,c,d,e if the conditions are met). Because the values are conditional, it might show up as a "" "" "" e "". So in the sumifs array formula it takes the array literal as values {"a","","","","e",""}, which causes an error. How do I make it so that the array is {"a","e"}?
edit: I realized after much effort that sumifs might not be the correct method as it requires alignment. For example, I might have a (1,0) criteria met from {PLoan, Deficit Loan} while X97:AC97 = (0,1,0,0,0,0). I do want the sum for that number but it won't sum due to the mismatch.
I got the below to work. If anyone can think of a way to incorporate wildcards as part of my string search, let me know...
=SUMPRODUCT(IFERROR(ISNUMBER(MATCH('Output'!$G$50:$G$69,$X$97:$AC$97,0)*MATCH('Output'!$C$50:$C$69,{"PLoan","Operating Deficit Loan"},0))*('Output'!$H$50:$H$69),0))
COUNTIF(S)/SUMIF(S) do not necessarily "require alignment" of the criteria being passed. It all depends upon what it is you wish to count.
If you require a count which comprises all combinations of the two sets of criteria, then it is sufficient that the two arrays containing those criteria be orthogonal.
At the moment, both of the criteria arrays which you are passing are of the same vector-type, i.e. row-vectors, since:
X97:AC97
is clearly a row- (horizontal) vector, as also is:
{"*PLoan","Deficit Loan"}
since, for English-language versions of Excel, the comma and semicolon represent, respectively, separators within row (horizontal) and column (vertical) array constants.
As such, in your case you simply need to transpose one of these two arrays, viz:
=SUM(SUMIFS(Output!$H$50:$H$69,Output!$C$50:$C$69,{"*PLoan";"Deficit Loan"},Output!$G$50:$G$69,X97:AC97))
(We could also transpose the other, viz:
=SUM(SUMIFS(Output!$H$50:$H$69,Output!$C$50:$C$69,{"*PLoan","Deficit Loan"},Output!$G$50:$G$69,TRANSPOSE(X97:AC97)))
or else move the entries within X97:AC97 to some other, vertical, range.)
See here for more information.
Regards
demo data
Either in Excel or in Statistical Package for the Social Science:
To combine the three columns into one and to be able then to calculate the statistics of the column. Mean, Median, Mode frequencies and all these.
I too have no idea why you want what it appears you do but assuming your values are numeric to two decimal places then with Excel I suggest in D1 and copied down to suit:
=TEXT(100*A1;"000")&TEXT(100*B1;"000")&TEXT(100*C1;"000")
this results in text strings. Should you want numeric output for further processing then a double unary can be applied:
=--(TEXT(100*A1;"000")&TEXT(100*B1;"000")&TEXT(100*C1;"000"))
In the latter case Excel will automatically strip any leading zeros. In the former case (should a number less than 1 be a possibility) the TEXT function preserves leading zeros.
Multiplication by 100 is to scale up the numbers to remove the decimal separators.
If the numbers are text then they may be concatenated and the commas removed with SUBSTITUTE:
=SUBSTITUTE(A1&B1&C1;",";"")
The above results in text strings which again may be converted with the double unary operator.