Formula logic for extracting specific cell data - excel

For extracting First £ figure and not the second one from sample data
(24M UNLTD+INS 30GB £347+£30 S6)
Following array formula has been used in Stackoverflow questions.
{=MID(A1,FIND("£",A1),MIN(IF(ISERROR(MID(MID(A1,FIND("£",A1)+1,999),ROW($1:$999),1)+0),ROW($1:$999),999)))}
I attempted an analysis of the formula as represented in the image below. I am not able to grasp the logic of part
MIN(IF(ISERROR(MID(MID(A1,FIND("£",A1)+1,999),ROW($1:$999),1)+0),ROW($1:$999),999))
As to how it leads to a figure of 4. Request that this part of formula be elaborated to clarify the role of various constituents of this formula.

Try the following as a standard (non-array) formula,
=--REPLACE(REPLACE(A2, 1, FIND("£", A2), ""), FIND("+", REPLACE(A2, 1, FIND("£", A2), "")), LEN(A2), "")
First the inside REPLACE(A2, 1, FIND("£", A2), "") erases everything up to the first £ symbol, then the same logic is applied to erase everything in that modified text from the first + to the end. The -- converts text-that-looks-like-a-number to an actual number.
The array formula you provided uses a more convoluted logic.
FIND("£", A2) + 1 finds the starting point of the first number after the first £ symbol. e.g. The first £ is the 20th character so it returns 21.
MID(A2, FIND("£",A2)+1, 999) extracts the text following that first £ symbol. The text might look like it starts with a number but it is text masquerading as a number. e.g. 347+£30 S6
In an array formula, ROW($1:$999) processes as a sequence of numbers from 1 to 999, incrementing by 1 for each cycle of calculation.
MID(MID(A1, FIND("£", A1) + 1, 999), ROW($1:$999), 1) + 0) returns an array of text values, each one 1 character long and 1 position deeper into the text than the previous one. e.g. 3, 4, 7, +, £, etc.
+0 is used to try and convert each of these pieces of text to a number. The IFERROR function returns TRUE if a piece of text cannot be converted to a true number. The first one that cannot be turned into a true number is the 4th e.g. +
The IF catches the TRUE on the fourth position and returns 4 from the second ROW($1:$999). It has returned 999 for positions 1, 2 and 3. e.g. 999, 999, 999, 4, 5, etc.
The MIN catches the smallest of these numbers returned as an array. This is where the 4 comes from. e.g. 999, 999, 999, 4, 5, 999, ...
You can see this yourself by changing all of the 999's to 9 then using the Evaluate Formula command. The reason changing to 9 is important is so that the returned arrays of number look like 1, 2, 3, 4, 5, 6, 7, 8, 9 which does not obfuscate the results quite a badly as 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ... 998, 999.
        This shows the formula evaluated several steps into the process. Note the 4 being returned to the MIN function.

Related

Excel formula that can identify 'mixed' sequences of binomially coded data?

Any help would be hugely appreciated!
If I have the following rows of data in Excel (5 examples below), whereby data is coded as 1 or 2, does anyone know an Excel formula that can identify/highlight the rows that contain a mixture of 1's and 2's?
I am only interested in sequences that have a mixture of 1's and 2's.
For example;
1, 2, 2, 2, 2, 1, 2, 2, 2 (this sequence has a mixture)
1, 1, 1, 1, 1, 1, 1, 1, 1. (this sequence does not have a mixture)
1, 2, 2, 2, 1, 1, 2, 2, 1. (this sequence has a mixture)
2, 2, 2, 2, 2, 2, 2, 2, 2. (this sequence does not have a mixture)
1, 1, 2, 2, 1, 1 , 2, 1, 1. (this sequence has a mixture)
Currently I use the following formula to highlight/identify the non-mixed sequences with only 1's or 2's;
=IF(ISERROR(FIND("222222222",TEXTJOIN("",TRUE,A1:A9))),FALSE,TRUE)
=IF(ISERROR(FIND("111111111",TEXTJOIN("",TRUE,A1:A9))),FALSE,TRUE)
But now I am in search of a formula that can bring up the mixture sequences.
One more option, for pre O365 - entered as array formula:
=OR(A1:H1<>I1)
Array formula after editing is confirmed by pressing ctrl + shift + enter
If you definitely want to identify rows containing a mixture of 1's and 2's, you could use countifs like this:
=AND(COUNTIF(A1:J1,1),COUNTIF(A1:J1,2))
If you wanted to be more concise, you could use
=VAR(A1:I1)>0
(All the answers solve the problem as stated. You could argue that my original answer is robust in the sense that it would cope with blank cells and out-of-range values like 0 or 3)
Alternatively maybe:
Formula in J1:
=MOD(SUM(A1:I1),9)>0
Or:
=COUNTIF(A1:H1,I1)<8
Or:
=SUM(A1:I1)<>I1*9
Or:
=STDEV(A1:I1)>0
As a conditional formatting formula I selected A1:I7 and, for example, used:
=STDEV($A1:$I1)>0
In J1 formula copied down :
=SUMPRODUCT(A1:I1-I1)<>0
Edit :
Explanation of the formula logic
Take this part of formula to check :
In K1, enter :
=SUMPRODUCT(A1:I1-I1) become >>
=SUMPRODUCT({1,2,2,2,2,1,2,2,2}-2) become >>
=SUMPRODUCT({-1,0,0,0,0,-1,0,0,0}) become >>
=-2
And
In K2, enter :
=SUMPRODUCT(A2:I2-I2) become >>
=SUMPRODUCT({1,1,1,1,1,1,1,1,1}-1) become >>
=SUMPRODUCT({0,0,0,0,0,0,0,0,0}) become >>
=0
Then
Since the range only have 2 number (1 or 2),
if the range minus any one number,
the range (all have the same number) the total sum must equal to "0",
else, "not 0"
Follow this logic, you can have another solution similar to Tom Sharpe's suggestion formula in using COUNTIF function
=COUNTIF(A1:J1,I1)<>COUNT(A1:J1)
If you have O365, you could use:
=COUNT(UNIQUE(A1:I1,TRUE))=2
will return TRUE if mixed, else FALSE

Is there an EXCEL formula that counts how many times Excel data 'switches' between binomial coding (i.e., data coded as 1 or 2)?

Folks, would really appreciate some help;
If I have the following values of data in Excel (3 examples below) where data is coded as 1 or 2, does anyone know an Excel formula which can count how many 'switches' occur in the sequence of values? What I mean by a 'switch', is when the 1's switch to 2's, and vice versa (when the 2's switch to 1's).
For example;
1, 1, 1, 1, 1, 1, 1, 2, 2 (there is 1 switch here)
1, 2, 2, 1, 1, 1, 1, 1, 1 (there are two switches here)
1, 2, 2, 1, 1, 1, 1, 2, 2 (there are three switches here)
So far, I am able to use the following formula (see below) to see IF there is a switch at all in the sequence (from 2 to 1 for example). But now I am trying to calculate how many switches are occurring in the sequence, and not IF a singular switch is occurring. So I think I possibly need to use a COUNT formula, instead of a FIND formula?
=IF(ISERROR(FIND("21",TEXTJOIN("",TRUE,[data range of a row]))),FALSE,TRUE)
Any help is appreciated.
If you have your data in cells A1 to I1, then use this formula:
=SUM(ABS(B1:I1-A1:H1))
I've tested this with your three inputs and it produces the expected answers.
If you would have access to FILTERXML (I believe from Excel 2013 onwards) you could use:
Formula in B1:
=COUNT(FILTERXML("<t><s>"&SUBSTITUTE(A1,", ","</s><s>")&"</s></t>","//s[following::*[1]!=.]"))
For your understanding; the xpath expression //s[following::*[1]!=.] will return all (child)nodes where the first following node is different then the current one. Then COUNT will actually count these returned numbers. Note that this will return 0 when no change occurs in your string.

Is there an Excel Formula which returns at WHAT POINT in an active string of data, data changes form (from 1 to 2)?

Folks, REALLY would appreciate help <3
If I have the following strings of data in Excel (3 examples below) where data is coded as 1 or 2, does anyone know an Excel formula which can tell me WHEN in the sequence the data switches from 1 to 2? i.e., in the example, at the 4th, 2nd, and 8th point/column along, out of the 9.
1, 1, 1, 2, 2, 2, 2, 2, 2.
1, 2, 2, 2, 2, 2, 2, 2, 2.
1, 1, 1, 1, 1, 1, 1, 2, 2.
So far, I am able to use the following formula (see below) to see IF there is a change from 1 to 2 in the sequence, but now need to know WHEN the change occurs.
=IF(ISERROR(FIND("21",TEXTJOIN("",TRUE,[data range of a row]))),FALSE,TRUE)
The Find() function actually return the position of the target string.
Instead of IF(ISERROR(..., use
=iferror(FIND("21",TEXTJOIN("",TRUE,[data range of a row])),FALSE)
and better link the previous post for system integrity purpose.
You just need to find the number '2' by using:
=ROUNDUP(FIND(2,A1)/3,0)

Using result of an Excel array function in a calculation

I am attempting to count instances of a particular value in Excel, from the last instance of a prior value.
Assume a vertical list starting in cell A1: 1, 2, 3, 4, 5, 4, 5, 3, 4, 5, 2, 3, 4, 3, 4, 2, 3, 4, 5
I can use an array function in, say B14 (A14 value: 3), of {=MAX(ROW($1:14)*(A$1:A14=A14-1)) to give me the row number of the last instance of a "2" (row 10).
I can then have, in C15, a function =COUNTIF(OFFSET(A14,0,0,B14-ROW(A14),1):A14,A14), which will count the instances of 3's since the last 2.
The question is: how do I integrate that array function directly into the final formula, so as not to have to waste a column with the interim calculation?
Edit
The list of numbers represents a level of indentation, so the end result will be a compound of these calculations with different offset checking to provide section numbering: 1; 1.1; 1.1.1, 1.2, 1.2.1, 1.2.2, etc
I want a single function that can calculate this entire depth level, without having to waste several columns identifying how many rows above the previous indent layer was defined.
Try in cell B14 this formula array:
{=COUNTIF(OFFSET($A14,0,0,
MAX(ROW($1:14)*($A$1:$A14=$A14-1))
-ROW($A14),1):$A14,$A14)}

Conditional Max/Min on Horizontally oriented data

Example data set
Right, above is a link to an image of a sub-segment of my data set. It is oriented in sets of 3 columns, with the first being a concentration, the second a qualifier, and the last an MDL - and continues for up to 95 samples (so a total of 285 columns making manual entry impractical) . How can i calculate the max or min of the concentration values for those that have a qualifier of "u" or vice versa have no qualifier?
I can't figure out anything, and unfortunately i don't have the time to re-orient the data. Anybody have an idea?
Perhaps something like this will do,
  
The 8 formulas in C7:J7 are,
=AGGREGATE(15, 6, $A2:$AY2/(($A$1:$AY$1=C$6)*($B2:$Z2="U")), 1)
=AGGREGATE(15, 6, $C2:$BA2/(($C$1:$BA$1=D$6)*($B2:$AZ2="U")), 1)
=AGGREGATE(14, 6, $A2:$AY2/(($A$1:$AY$1=E$6)*($B2:$Z2="U")), 1)
=AGGREGATE(14, 6, $C2:$BA2/(($C$1:$BA$1=F$6)*($B2:$AZ2="U")), 1)
=AGGREGATE(15, 6, $A2:$AY2/(($A$1:$AY$1=G$6)*($B2:$Z2<>"U")), 1)
=AGGREGATE(15, 6, $C2:$BA2/(($C$1:$BA$1=H$6)*($B2:$AZ2<>"U")), 1)
=AGGREGATE(14, 6, $A2:$AY2/(($A$1:$AY$1=I$6)*($B2:$Z2<>"U")), 1)
=AGGREGATE(14, 6, $C2:$BA2/(($C$1:$BA$1=J$6)*($B2:$AZ2<>"U")), 1)
Those cover both minimum and maximum values when either including or excluding the qualifier.
Addendum: Excluding blank cells
One more condition to check the LEN of the values can be added. To change the length of the value into a divide-by-1 (unchanged) or divide-by-0 (#DIV/)! error) wrap the LEN in the SIGN function.
=AGGREGATE(15, 6, $A2:$AY2/(SIGN(LEN($A2:$AY2))*($A$1:$AY$1=C$6)*($B2:$Z2="U")), 1)
I'm retaining the SMALL sub-function as only AGGREGATE's sub-functions 14 and up process as an array.

Resources