Extracting Wanted Data from the Raw Cell - google-sheets

I have been trying to extract the required data from a single cell and I have tried using some common formulas but its not working for all the cells exactly.
I would appreciate your help in this regards.
Google Sheet
Formula 1
=LEFT(A2,FIND(C2,A2)-1)
Formula 2
=SUBSTITUTE(TRIM(SUBSTITUTE(SUBSTITUTE(LEFT(RIGHT(A2,len(A2)-FIND(") ",A2)),6),")",""),"(","")),"|","")

I duplicated your tab and entered the following formula in cell E2:
=ArrayFormula(ifna(regexextract(A2:A,"\[\s\]\s(.+)?\s\((.+)\)")))
Explanation
\[\s\]\s - find [ ]
(.+)?\s\( - extract everything after it until the next occurence of (
(.+)\) - extract everything after the above ( and before the next occurence of )

EDIT: The first time I've tried #ztiaa answer it didn't work... don't know why. I kept investigating REGEX and gave it another try, and it did... You'd probably prefer that. I leave my answer just as a memory, and if it's useful for someone else in another scenario
Honestly, I don't handle regex as #ztiaa, but what I've found difficult about your example is that there are sometimes more than one opening parenthesis... that's why I looked for a way of finding the last appearance of "(". You can learn more about this workaround here
I changed "#" with "CUT HERE" in my example, just in case "#" may appear in your example. With that in mind, you can set these two formulas:
=ArrayFormula(IF(A3:A="","",MID(A3:A,5,FIND("CUT HERE",SUBSTITUTE(A3:A,"(","CUT
HERE",LEN(A3:A)-LEN(SUBSTITUTE(A3:A,"(",""))))-5)))
=arrayformula(if(A3:A="","",mid(A3:A,FIND("CUT HERE",SUBSTITUTE(A3:A,"(","CUT
HERE",LEN(A3:A)-LEN(SUBSTITUTE(A3:A,"(",""))))+1,FIND(")",A3:A,FIND("CUT
HERE",SUBSTITUTE(A3:A,"(","CUT
HERE",LEN(A3:A)-LEN(SUBSTITUTE(A3:A,"(",""))))+1)-FIND("CUT
HERE",SUBSTITUTE(A3:A,"(","CUT
HERE",LEN(A3:A)-LEN(SUBSTITUTE(A3:A,"(",""))))-1)))
The second one is really long because it has to find the amount of characters in between brackets. But it appears to work. Probably there's a more ellegant way with Regex, I repeat :)
Look in J and K of your example:

Related

Split Function with Index Match function

I have a column that has multiple comma separated values, I need to use Split function and then run index match on that column, is it possible ? if yes somebody can help pls
Yes, you can do this, I just tested it in google sheets.
=INDEX(<array>,MATCH(SPLIT(<cell>,","),<array>,0))
To be honest, I was googling for something similar and ran across this issue. My problem turned out to be that I was using ',' and NOT ",". I suspect you asked this question for similar reasons (you tried it and it didn't work). So just to confirm, it is totally possible, the issue is likely an error with your formula.
output of a minimal example, using the above formula, matching on the first split:

=LEN Function in Google Sheet not working corretly

I have a column with lots of rows containing text. I want to highlight cells with over an x-amount of characters, but how? The code I'm using in combination with 'Conditional Formatting' is not working all the time. Sometimes it highlights text over the x amount and sometimes it doesn't, so there is something I'm doing wrong here. The x-amount in the example below is: 300.
you may also need to lock it like:
=LEN(E$1:E$170)>300
Silly me... I found the answer myself. I need to put in the same range in the formula as well. Formula with the range E1:E170 needs to be: =LEN(E1:E170)>300

Countif function not counting word with an apostrophe

I’ve looked through the forum, but haven’t found a solution. I’ve got some survey responses in a table like so:
It’s okay
I don't like school
It’s okay
Good, I like it
I’m using a countif function to count the number of times each response was received in the survey. The thing is my function works well with these values:
I don’t like school
Good, I like it
but my function does not pick up the phrase
It’s okay
As I’m using named ranges, the formula I am using is:
=COUNTIF(Question,"It's okay")
Please see this shared link for the example file and check out sheet 2 for the actual formula.
https://drive.google.com/open?id=1e1ccJh3TDeOsIrcn0f5ewQ3M6xOuBrfKBqqJ3mzXfV0
Initially, I thought the issue was that the countif function wasn’t working because of the apostrophe in the word “it’s okay”. As you can see from my example, there are other words with apostrophes in them that get counted so I’m baffled as to why this function is not working for the phrase “it’s okay”.
Has anyone seen this problem before, or any ideas as to how I could accomplish the same thing using another process?
I’ve also tried to escape the apostrophe like so :
=COUNTIF(Question,"It''s okay")
=COUNTIF(Question,"It\'s okay")
But neither case made any difference.
Many thanks in advance
That's because you have different apostrophes in data and in formula:
’ ("Right single quotation mark", ASCII code 146) in data
' ("Single quote", ASCII code 39) in formula

What would short versions of given formulas be and how do you do it in general?

I am studying for a test and I would really appreciate some help with this. The instructions are simply to write these formulas in a shorter version. I understand how IF works; if the expression is true, it returns the first value, otherwise the second one (they are separated by semicolons).
Given examples are:
=D$5+IF(C4>1;F8-A12/4-53;F8-A12/4-B12+1)
=IF(C4="test";A4-55+C13;22+(C13+B2+A4))
=C3*IF(AND(C4="P";C5="P");4*A4/(1-m);m*A4-n*A4);
=IF(B3<>0;2*C6;2*IF(B3=2;SIN(omega*t-$A$2);0)
Explanation will be greatly appreciated.
The first formula can be shortened to:
=D$5+F8-A12/4+IF(C4>1;-53;-B12+1)
It's just a matter of factoring out F8-A12 since it is used twice.
To test this, I filled in some numbers into the cells mentioned, and it produced the correct result.
Similarly in the second formula, A4 and C13 are used twice and they could be factored out to be used only once.
In the third formula, everything is getting multiplied by A4 so it could be factored out.
In the fourth formula, it looks like 2 is the only thing that could be factored out.

How can I use the OFFSET() formula with a range of values?

EDIT: Disclaimer about the XY problem: The actual, concrete problem I'm trying to solve is: How can I make "recursive" (is that the right term here?) formulas that use infinite ranges in Google Spreadsheets/Excel? The solution I'm working with involves the OFFSET() formula. I'm asking this question because I'd like to get an extensible understanding of the way formulas use and implement ranges, especially infinite ranges.
I'm working in Google Spreadsheets and trying to create ArrayFormulas that will automatically expand without needing to use the fill handle as new data is added in the requisite columns.
To do this, I want to use infinite ranges such as A2:A when I do calculations so that no matter how much data is added, I'll never have to drag-fill any data or formulas and I can just let the spreadsheet iterate and do the work.
I'm running into a problem, though, when I try to use these infinite ranges with the OFFSET() formula. What I'm trying to do is have each cell in the range pull values from a couple of the cells next to it (thus the offset), do a simple calculation with those values, and make that the new cell value. But because the formula interprets the instruction as attempting to offset an entire (infinite) range of values, it returns a #REF! error. Here's a shared example sheet that demonstrates what I'm trying to do.
https://docs.google.com/spreadsheets/d/1V3ldSBoCrzyVWcn66wFBkDOmxt6iuYgtiU_H4KQ6J14/
If for some reason you can't see the formulas, the formulas I'm using are:
C3 =ArrayFormula(Offset(C3:C, 0, -1) - Offset(C3:C, -1, -1))
F4 =Arrayformula(Offset(F3:F, 0, -1) + Offset(F3:F, -1, 0))
Both of these return a #REF! error. C3's alt-text reads: "Error: Result was not automatically expanded, please insert more rows (1)." F3's alt-text reads: "Error: Circular dependency detected."
I'm decently confident why these don't work - you're apparently not allowed to use and refer to ranges this way. I don't, however, know how to fix this.
The two use-cases in the spreadsheet are essentially the same thing, backwards. Chances are if I can figure out one I can reverse-engineer it to work for the other one, but I've had no luck so far.
I've Googled around a lot and while I've never found anything that solves this problem, a lot of similar problems seem to be solved by using the INDIRECT() function. I can't understand how this would apply here, though, that function seems to be strictly for parsing values dynamically from cells with variable input.
(I should probably mention that this data is on a back end sheet and it's getting pulled on another sheet to display some charts on the front end. I wouldn't ask a question here if this data was the only thing involved.)
Any help or a step in the right direction would be appreciated.
If I'm understanding your question, one way to make an offset function expand automatically is to attach a count function, eg. in excel
=offset(C2,,,counta(C:C))
However, this will give you a circular reference error. To address this issue, this is one solution that I have used:
"OFFSET(C3,,,MATCH(9.99999999999999E+307,OFFSET(C3,,,ROWS(C:C)-ROW(C3))))"
This function passes an array based on the last number cell in the column. And for it to be used properly, it needs to be wrapped in a function that can handle arrays, like SUM().

Resources