How to combine the cell removing empty values in column in excel - google-sheets

Need to get that output : Empty cells should be removed and need to get all that in 2 columns without empty cells.

try in GS:
=ARRAYFORMULA(IF(A:B=""; C:D; A:B))
={QUERY(FLATTEN(A1:G), "where Col1 is not null skipping 2"),
QUERY(QUERY(FLATTEN(A1:G), "where Col1 is not null offset 1"), "skipping 2")}

Related

Google Sheets multiply values in cell by both integer in same cell and number of TRUE in same row

I have the following formula:
=ARRAYFORMULA(QUERY(IFERROR(FLATTEN(SPLIT(FLATTEN(REPT(REGEXEXTRACT(SPLIT(A1:A4, " "),
"(?:\d+x)?(.+)")&"×", IFERROR(REGEXEXTRACT(SPLIT(A1:A4, " "), "(\d+)x"), 1)*1)), "×"))),
"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1)''"))
This counts the number of entries in column A, extracting the variable text like 2x and 1x, then lists them as unique cells accompanied by a count of each (while ignoring empty cells).
Now, I'd like to modify this to count associated checkboxes in 3 previous columns, comparing with the unique entries of the original column, as well as comparing the variable number of 2x and 1x so that it appropriately assigns the values.
In other words, I want it to turn out like so:
I've tried to modify the previous formula by adding (what I thought was) an additional range to the second FLATTEN.
=ARRAYFORMULA(QUERY(IFERROR(FLATTEN(SPLIT(FLATTEN(REPT(REGEXEXTRACT(SPLIT(D1:D14, " "),
"(?:\d+x)?(.+)")&"×", IFERROR(REGEXEXTRACT(SPLIT(D1:D14, " "), "(\d+)x"), 1)*1)), "×"),
SPLIT(REPT(COUNTIF(A1:A=true,D4:D<>"")*1), "×"))),
"select Col1,count(Col1) where Col1 is not null group by Col1 order by count(Col1) DESC label count(Col1)''"))
Among many others as I've begun to understand the formula given, I also tried a very roundabout way, first removing the QUERY part of the above to separate the Unique Strings into one column, and count into the other:
=FLATTEN(REPT(COUNTIF(B1:C=true,D1:D=F1),IFERROR(REGEXEXTRACT(SPLIT(N4:N56, " "), "(\d+)x"), 1)*1))
None of those worked.
So again, how would I get the following results?
try:
=ARRAYFORMULA(QUERY(""&IFERROR(FLATTEN(SPLIT(FLATTEN(
IF((A1:C15=TRUE)*NOT(REGEXMATCH(D1:D15, "\d+x")), D1:D15,
IF(REGEXMATCH(D1:D15, "\d+x"), REPT(REGEXEXTRACT(SPLIT(D1:D15, " "), "\d+x(.*)")&"×",
REGEXEXTRACT(SPLIT(D1:D15, " "), "(\d+)x")*1), ))), "×"))),
"select Col1,count(Col1) where Col1 is not null group by Col1
order by count(Col1) DESC label count(Col1)''"))

Google Sheets complex array from multiple sheets

I am looking to build a formula that will check columns for a true value and if true return the first column name, in order...
Below is the formula I have been trying to build but it is not working as expected although I think I am close.
=ARRAYFORMULA(IF(HLOOKUP($A16,{Sheet1!$B$2:$E$5,Sheet2!$B$8:$E$11},{3,4,5},0)=TRUE,{Sheet2!$A$3:$A$5,Sheet1!$A$3:$A5,""))
Let me illustrate. Sheet 1 and Sheet 2 contain names with who has what (checkbox items). With a formula in cell B16 that will populate both to the right and down with all the names that contain a TRUE value in the looked up value (A:A).
Above image was manually typed in, the formula does not work at all.
Please help!
EDIT: Link to sheet
try:
=INDEX(IFERROR(VLOOKUP(A14:A, SUBSTITUTE(REGEXREPLACE(SPLIT(FLATTEN(
QUERY(SUBSTITUTE(QUERY(SPLIT(FLATTEN(
IF({B3:E5; B9:E11}=TRUE,
{B2:E2&"♦"&A3:A5&"♣"&ROW(A3:A5);
B8:E8&"♦"&A9:A11&"♣"&ROW(A9:A11)}, )), "♦"),
"select max(Col2) where Col2 is not null group by Col2 pivot Col1"),
" ", "♥"),,9^9)), " "), "(♣\d+)", ), "♥", " "),
SEQUENCE(1, COUNTUNIQUE(B2:E2, B8:E8))+1, 0)))
demo sheet
Here is another approach (similar to player0's, but different enough to warrant the separate answer:
=ArrayFormula(IFERROR(TRIM(SPLIT(VLOOKUP(FILTER(A3:A,A3:A<>""),REGEXREPLACE(SPLIT(FLATTEN(QUERY(QUERY(SPLIT(QUERY(FLATTEN({IF(Sheet1!B2:E<>TRUE,,Sheet1!B1:E1&"~|"&Sheet1!A2:A&",");IF(Sheet2!B2:E<>TRUE,,Sheet2!B1:E1&"~|"&Sheet2!A2:A&",")}),"Select * WHERE Col1 Is Not Null"),"|"), "Select MAX(Col2) where Col2 IS NOT NULL GROUP BY Col2 PIVOT Col1"),, 9^9)),"~"),"[,\s]+$",""),2,FALSE),","))))
I've added it into your spreadsheet in a new sheet ("Erik Help").
If you have more than two sheets' to include, just find this section of the formula and continue the pattern:
{ IF(Sheet1!B2:E<>TRUE,,Sheet1!B1:E1&"~|"&Sheet1!A2:A&","); IF(Sheet2!B2:E<>TRUE,,Sheet2!B1:E1&"~|"&Sheet2!A2:A&",") }

Google Sheets - transpose column data in groups into rows

I am trying to transpose data from column A to single rows. The original data has 3 rows for each name. But there could be either 1 or several jobs for each day. Each day needs to be treated separately, but this maybe best handled by manually adding at the beginning of each day.
This is for a fortnightly timesheet, therefore the number of rows in unpredictable.
The 1st image is my original data. the 2nd is the desired end result.
The data is to transposed to any blank rows in columns b, c, d, e,
as long as there are no blank rows, I can then reference them with my formulas.
to place the information into the appropriate cells within
the timesheet. I already have working formulas to do this.
the transpose section is what I need help with
Here is a link to my file
https://docs.google.com/spreadsheets/d/1PhuFXDB2H1c9ua6szjhJEgJR91yXHhZAmn_2UGOBvIo/edit?usp=sharing
try:
=ARRAYFORMULA({QUERY(IF(REGEXMATCH(A12:A, "\d+:\d+.*"), VLOOKUP(ROW(A12:A),
IF(IF(IFERROR(RIGHT(A12:A, 4)*1)>2000, A12:A, )<>"", {ROW(A12:A),
IF(IFERROR(RIGHT(A12:A, 4)*1)>2000, A12:A, )}), 2, 1), ), "where Col1 is not null"),
QUERY(IF((IFERROR(RIGHT(A12:A, 4)*1)>2000)+(REGEXMATCH(A12:A, "\d+:\d+.*")),, A12:A),
"where Col1 is not null skipping 2"),
QUERY(QUERY(IF((IFERROR(RIGHT(A12:A, 4)*1)>2000)+(REGEXMATCH(A12:A, "\d+:\d+.*")),, A12:A),
"where Col1 is not null offset 1", 0), "skipping 2"),
FILTER(A12:A, REGEXMATCH(A12:A, "\d+:\d+.*"))})
If you want a solution with a formula in one cell only, try:
=arrayformula({"date","name","job type","start - end time";query(split(flatten(query(iferror(datevalue(A12:A),),"where Col1 is not null",0)&split(flatten(split(textjoin(char(9999),1,if(regexmatch(to_text(A12:A),":+.*-+"),A12:A&char(9998),if(iferror(datevalue(A12:A),)<>"",char(10001),A12:A))),char(10001))),char(9998))),char(9999)),"where Col2 is not null",0)})
in put B12 :
=IFERROR(if(FIND("2021",A12)>=1,0,""),B11+1)
in put C12 :
=if(B12=0,A12,C11)
in D12 :
=if(mod(B12,3)=1,TRANSPOSE(A12:A14),"")
and drag downwards. Then in F12 put :
=FILTER(C:F,F:F<>"")
and drag downwards.
Idea : use transpose() with a conditional counter. use (F12)filter to remove blank.
Please if it works/understandable/not.

Expected result in one Column without nulls

want to get the output in single column from multiple columns. Please check the below example for your reference.
use:
={QUERY(FLATTEN(A1:G), "where Col1 is not null skipping 2"),
QUERY(QUERY(FLATTEN(A1:G), "where Col1 is not null offset 1"), "skipping 2")}

How to remove extra line break/empty cell Google Sheets importrange/query

Here is my formula (I have edited the name of my sheet as I cannot allow access to it).
=QUERY(IMPORTRANGE("my sheet","Prices"),"select Col1 where Col4 contains '"& L1 &"' limit 1",1)
This is working perfectly for all entries except 1 of them where it is importing 2 cells (the first one blank, the second with the desired result). Since the cell below is filled it cannot overwrite it, and I don't want it to. What would cause this phantom empty cell and how do I prevent it from happening?
if the blank undesired cell is in the first column add and Col1 is not null like:
=QUERY(IMPORTRANGE("my sheet", "Prices"),
"select Col1
where Col4 contains '"&L1&"'
and Col1 is not null
limit 1", 1)
if you have actual line break issue use regex with \n like:
=ARRAYFORMULA(REGEXREPLACE(QUERY(IMPORTRANGE("my sheet", "Prices"),
"select Col1
where Col4 contains '"&L1&"'
limit 1", 1), "\n", ))

Resources