Splitting Cell into Multiple row using array - google-sheets

I am trying to split the range of data like this :-
At first I was using this :-
=ARRAYFORMULA(IF(ROW($B$2:$B)>=(SUM($A$2:$A)+ROW()),"",IFERROR(SPLIT(LOOKUP(ROW($B$2:$B)-ROW(),IF(ROW($B$2:$B)>=(SUM($A$2:$A)+ROW()),"",SUMIF(ROW($A$2:$A),"<"&ROW($A$2:$A),$A$2:$A)),A2:A),"🙂"),"")))
But this didn't worked, I got this from another stack answer, I know this is not right :(, I can't reach anywhere with this
This is the sheet URL :- https://docs.google.com/spreadsheets/d/1oB1i0IAGoCVN0ynKBXDQcmEd3c_mpOdmWVFo7Gz-vyk/edit#gid=0
Thanks

Formula for you
=TRANSPOSE(SPLIT(JOIN(CHAR(10),A2:A7),CHAR(10),1,0))
Function References
JOIN
SPLIT

REDUCE the array by SPLITting by CHAR(10):
data
Intended Result
1
1
123
1
2
3
=REDUCE("Intended Result",A2:A5,LAMBDA(a,c,{a;IFERROR(TRANSPOSE(SPLIT(c,CHAR(10))))}))

Related

How to extract text from cells with distinct

I tried different approaches to accomplish what I am looking for and it might not be possible with how I have formated my data but I will try to explain it to see if there is a way.
My origin of data looks like the following:
Case
HELP
100
HELP-01
HELP-02
101
HELP-01
102
103
HELP-03
What I want is to be able to extract the HELP-* into another column without duplicate values and one after another. The result I am looking for is from the above table been able to have this:
HELP
HELP-01
HELP-02
HELP-03
Is there a way to do this in Google Sheets?
Thank you,
Alternatively you can use:
=UNIQUE(QUERY(FLATTEN(B2:C),"where Col1 like 'HELP-%'"))
The QUERY() will now only return those values that start with 'HELP-' in the case you might have other string-values.
A littel more specific even, could be to use:
=UNIQUE(QUERY(FLATTEN(B2:C),"where Col1 matches 'HELP-\d+'"))
Where 'matches' will now use the regular expression to only return values that start with 'HELP-' but end with any 1+ digits.
Try this in Google Sheets
=sort(array_constrain(unique(flatten(B2:C)),counta(B2:C),1))

Is it possible to use an array within a Google Sheets function

Is it possible to have an array within a formula, as opposed to referencing the array in cells.
For example with VLOOKUP, I have tried to do this but it doesn't work:
=VLOOKUP(I2,[["Superking",4],["King",3],["Double",2],["Single",1]],2,0)
I'm essentially trying to incorporate the below table into the formula itself:
Superking 4
-----------------------------
King 3
-----------------------------
Double 2
-----------------------------
Single 1
I thought that this is maybe possisble but expressing the array incorrectly.
I do know that this can easily be done by putting the actual data into the sheet, but I am interested to know if it is posisble to do it this way.
This seems to work:
=vlookup("Pete", {{"John",9};{"Pete", 2}}, 2, false)
Yeah, this is the format to do it.
={"one","two","three","four","five";1,2,3,4,5}
will produce

Union between two arrays in Google Sheets

I've got the following tables:
First
1
Second
2
Third
3
Fourth
4
I want to build a formula that bring both together vertically, so that I end up with a big table like this:
First
1
Second
2
Third
3
Fourth
4
I've tried using standard union formulas like {table1, table2} but it adds table2 horizontally, not vertically.
Any thought on how I would go about doing this?
When using curly braces, a comma ({table1, table2}) separates data into columns on the same row, while a semi-colon ({table1; table2}) will put table2's data into the row after table1's data.
I presume that your local parameters will ask you tu write it as following
{table1; table2}

Duplicating data in one cell as per repeat counter

I got into a bit of problem. I have data like this
Date Repeat
7-Oct-2018 1
8-Oct-2018 1
9-Oct-2018 2
10-Oct-2018 2
11-Oct-2018 3
12-Oct-2018 2
13-Oct-2018 1
Now the result i want is a column where the date is repeated as per the repeat numbers, like this.
Result
7-Oct-2018
8-Oct-2018
9-Oct-2018
9-Oct-2018
10-Oct-2018
10-Oct-2018
11-Oct-2018
11-Oct-2018
11-Oct-2018
12-Oct-2018
12-Oct-2018
13-Oct-2018
So how can i get this result. Please do help
I tried to think of it for own study. For example, how about this sample formula? I think that there might be simpler formulas. So please think of this as one of them. When you use this, please put the following formula to a cell.
=TRANSPOSE(SPLIT(JOIN(",",ARRAYFORMULA(REPT(A2:A8&",",B2:B8))),","))
This formula supposes that the values of Date and Repeat are put in A2:A8 and B2:B8, respectively.
Show repeatedly Date using REPT(). At this time, , is used as a delimiter.
Join each cell with , using JOIN().
Split the cell with , using SPLIT().
Transpose the cells using TRANSPOSE().
I think that you can also use CONCATENATE() and TEXTJOIN() for joining cells.
References:
REPT
JOIN
SPLIT
TRANSPOSE
CONCATENATE
TEXTJOIN

QUERY() to get rows below a certain cell

I'm downloading a CSV file from an external API. It returns a table with the following structure:
foo
bar 1 4
baz 2 3
Is there any way to make a QUERY (or some other function?) to get the first two rows below the foo cell?
There are several other occurrences of bar and baz rows, that's why I only want the ones below the foo cell. Doable?
Here is one alternative also: using regexextract and concatenate , with the additional rept function to grab each of the values , pretending the url is in A1:
=regexextract(concatenate(IMPORTDATA(A1)),"(Basic)"&rept("(\d\.\d{1,3})",6))
=regexextract(concatenate(IMPORTDATA(A1)),"(Diluted)"&rept("(\d\.\d{1,3})",6))
comes out looking like this:
if you want to be doubly sure: add the Earnings per share in front of basic:
=regexextract(concatenate(IMPORTDATA(A1)),"Earnings per share(Basic)"&rept("(\d\.\d{1,3})",6))
=regexextract(concatenate(IMPORTDATA(A1)),"Earnings per shareBasic.*(Diluted)"&rept("(\d\.\d{1,3})",6))
To have the output all on one line, one after the other:
=regexextract(concatenate(IMPORTDATA(A1)),"Earnings per share(Basic)"&rept("(\d\.\d{1,3})",6)&"(Diluted)"&rept("(\d\.\d{1,3})",6))
Basically if you want to see the raw data , remove the regex part and just leave the concatenate and the importdata - the regex part helps to ignore the beginning portion and then specify which pieces to capture using the parentheses. These are called capture groups. Anything outside of them technically gets ignored.
try this formula:
=QUERY(FILTER(A1:C13,row(A1:C13)>MATCH("foo",A1:A13,0)),"select * limit 2")
example workbook
To use imported data instead of range, use:
=QUERY(FILTER(Data,row(Data)>MATCH("foo",query(Data,"select Col1"),0)),"select * limit 2")
Try:
=query(A2:C,"select * where A='bar' or A='baz' limit 2")

Resources