I have lists on data in several sheets within one workbook, I would like to use an Array type of formula to bring together one long list of all the data in row A.
But I would only like to bring across some of the sheets data, which I have said "yes" to.
As the data in sensitive I have setup a dummy spreadsheet which emulates my setup.
I seem to be able to get one sheet on data to array, but I can't get the others.
=if(Sheet1!$B2>0,{indirect(Sheet1!$A2&"!$A2:$A")})
Can anyone help me?
Sheet2 is where I want to import the data into.
https://docs.google.com/spreadsheets/d/1Y1OMfEdpMIcptnkuHRD2dNQNI5iUeidkuKnRu08Y_jA/edit#gid=703073676
today you can use:
=QUERY({
IF(Sheet1!B2="y", INDIRECT(Sheet1!A2&"!A2:A"), );
IF(Sheet1!B3="y", INDIRECT(Sheet1!A3&"!A2:A"), );
IF(Sheet1!B4="y", INDIRECT(Sheet1!A4&"!A2:A"), );
IF(Sheet1!B5="y", INDIRECT(Sheet1!A5&"!A2:A"), );
IF(Sheet1!B6="y", INDIRECT(Sheet1!A6&"!A2:A"), );
IF(Sheet1!B7="y", INDIRECT(Sheet1!A7&"!A2:A"), );
IF(Sheet1!B8="y", INDIRECT(Sheet1!A8&"!A2:A"), )},
"where Col1 is not null", )
and from 1st Oct, 2022 you can try:
=QUERY(BYROW(FILTER(Sheet1!A2:A, Sheet1!B2:B="y"),
LAMBDA(x, INDIRECT(x&"!A2:A"))), "where Col1 is not null", )
Related
I'm trying to dynamically offset data of multiple rows to match the header column in Google Sheets. The first tab contains data of multiple fruits and how many are harvested on a particular day. Each fruit starts harvesting on different dates, and the dates might not be continuous.
The second tab, "Fruit bank", shows how many fruits are harvested in total for each day. Column D is a continuous set of dates. In cell E1, a QUERY formula dynamically pulls the names of the fruits so whenever a new fruit is added, it shows up here as well. In cell E2 and the rest of the row, I use VLOOKUP formulas to pull the data from the first tab. What I need help with is to write a formula on cell E2 that expands to the rest of the row so I don't have to manually type in the lookup range every time a new fruit is added.
Also, I suspect there're better functions to use than the VLOOKUP because the way VLOOKUP pulls data is very slow. I could literally see it loading even with this small dataset.
Yellow cells contain formula.
I appreciate anyone who can take a look at my spreadsheet (linked below) and see what's the best solution for this. The 3rd tab is editable.
https://docs.google.com/spreadsheets/d/14GeJKgxadInNWVVyft2gilae7HOIEvKXRop-Kz_On-Q/edit#gid=53523977
Thanks! J
Use filter(), like this:
=arrayformula(
ifna(
vlookup(
$D2:$D,
{
filter(
'Fruits data'!$B2:$AA,
'Fruits data'!$A1:$Z1 = E1
),
filter(
'Fruits data'!$A2:$Z,
'Fruits data'!$A1:$Z1 = E1
)
},
2, false
)
)
)
See your sample spreadsheet.
you can try either. added solutions here and here
=BYROW(D2:D,LAMBDA(dx,IF(dx="",,BYCOL(E1:1,LAMBDA(ex,IF(ex="",,XLOOKUP(dx,FILTER('Fruits data'!1:46,COLUMN('Fruits data'!1:1)=MATCH(ex,'Fruits data'!1:1,0)-1),FILTER('Fruits data'!1:46,'Fruits data'!1:1=ex),)))))))
OR
=MAKEARRAY(COUNTA(D2:D),COUNTA(E1:1),LAMBDA(r,c,XLOOKUP(INDEX(D2:D,r),FILTER('Fruits data'!1:46,COLUMN('Fruits data'!1:1)=MATCH(INDEX(E1:1,,c),'Fruits data'!1:1,0)-1),FILTER('Fruits data'!1:46,'Fruits data'!1:1=INDEX(E1:1,,c)),)))
try this with dates:
=ARRAYFORMULA(QUERY({
FLATTEN(FILTER('Fruits data'!A2:100, ISODD(COLUMN('Fruits data'!A2:2)))),
FLATTEN(FILTER('Fruits data'!A2:100, ISEVEN(COLUMN('Fruits data'!A2:2)))),
FLATTEN(IF(FILTER('Fruits data'!A2:100, ISEVEN(COLUMN('Fruits data'!A2:2)))="",,
FILTER('Fruits data'!A1:1, ISEVEN(COLUMN('Fruits data'!A2:2)))))},
"select Col1,sum(Col2) where Col2 is not null group by Col1 pivot Col3"))
which could be simplified:
=ARRAYFORMULA(LAMBDA(x, QUERY({
FLATTEN(FILTER(x, ISODD(COLUMN(X)))),
FLATTEN(FILTER(x, ISEVEN(COLUMN(x)))),
FLATTEN(IF(FILTER(x, ISEVEN(COLUMN(x)))="",,
FILTER(OFFSET(x, -1,,1), ISEVEN(COLUMN(x)))))},
"select Col1,sum(Col2) where Col2 is not null group by Col1
pivot Col3 label Col1'Date'"))('Fruits data'!A2:100))
I am trying to import a table from Binance fees (https://www.binance.com/en/fee/depositFee) to Google Sheets (buy i am trying into MS Excel).
When i get data, i dont know how split files for each network type.
Now, i have data like this:
=IMPORTHTML("https://www.binance.com/en/fee/depositFee"; "table"; 0)
Thanks!!!
One solution is, after importing data as you did, is to split each line as following
=iferror(transpose(flatten(arrayformula(transpose(split(transpose(C3:F3),char(10)))))),"")
You will get multiple blocks of 4 columns. And finally you can group data like this way, assuming there is a max of 4 blocks :
=query({query( 'raw data'!A3:V,"select A,B,G,H,I,J");query('raw data'!A3:V,"select A,B,K,L,M,N");query('raw data'!A3:V,"select A,B,O,P,Q,R");query('raw data'!A3:V,"select A,B,S,T,U,V")},"select * where Col3<>'' order by Col1")
https://docs.google.com/spreadsheets/d/1JCjJywK9qPprynX2byvAnU7jS4S9cAYmHAfLcuyW3oQ/edit?usp=sharing
I can offer a solution* with a formula in one cell that works over your importrange data (shown in cell H1 below):
=arrayformula(
{query(IFERROR(array_constrain(
{"Coin/Token","Full Name","Network","Minimum Withdrawal","Deposit fee","Withdrawal Fee";
flatten(split(rept("|"&A3:A,LEN(regexreplace($C3:$C,"[^\n]",""))+1),"|"))
,flatten(split(rept("|"&B3:B,LEN(regexreplace($C3:$C,"[^\n]",""))+1),"|"))
,flatten(split(C3:C,CHAR(10)))
,flatten(split(D3:D,CHAR(10)))
,flatten(split(E3:E,CHAR(10)))
,flatten(split(F3:F,CHAR(10)))
},
max(IF(A3:A<>"",LEN(regexreplace($C3:$C,"[^\n]",""))+1,))*COUNTA(A3:A),
6)
,),"where Col1 is not null",0)
})
It expands the cells in columns C,D,E and F where there are multiple items in C. It also repeats values from columns A and B.
Columns D and F correctly convert to numbers.
Formula updated with Mike Steelson enhancements and player0 LEN/REGEXREPLACE.
all you need is:
=INDEX(TRIM(TRANSPOSE(SPLIT(FLATTEN(QUERY({REPT(ARRAY_CONSTRAIN(
IMPORTHTML("https://www.binance.com/en/fee/depositFee", "table", 1), 9^9, 2)&
"×", 1+LEN(REGEXREPLACE(INDEX(""&
IMPORTHTML("https://www.binance.com/en/fee/depositFee", "table", 1),, 3),
"[^\n]+", ))), REGEXREPLACE(QUERY(
IMPORTHTML("https://www.binance.com/en/fee/depositFee", "table", 1)&
"×", "select Col3,Col4,Col5,Col6", 1), "\n", "×")},,9^9)), "×"))))
I am importing data from two different Google sheets and merging them in another sheet. The formula which I used is as below .
=QUERY({
IFERROR(QUERY(
{ IMPORTRANGE("" , "Sheet1!$A$1:$b") },
"SELECT Col1,Col2 WHERE Col2='Total'",
0
)) ;
IFERROR(QUERY(
{ IMPORTRANGE("" , "Sheet1!$a$1:$b") },
"SELECT Col1,Col2 WHERE Col2='Yes'",
0
))
})
In above formula, importrange is giving the result when both sheets have data to import, but if any one sheet has no data to import the data from another sheet is not getting imported. I had figured a solution at below link where we can handle this issue by using dummy column reference, this approach is fine when we have few sheets to import with few columns but when we are importing from many sheets and many column to import the dummy column reference gets too long. Is there any other way to solve this issue.
The easiest way to do this is to use an IFERROR(SEQUENCE(1,n)/0) as your output for when a query of an importrange fails instead of needing to list a bunch of blanks.
The solution for your simple example looks like this where n = 2:
=ARRAYFORMULA(QUERY({IFERROR(QUERY({IMPORTRANGE("1hea986JF3plR_tn7plNRgjWhiGqxOlR8s8yE-Ri6FfU" , "Sheet1!$A$1:$b")}, "SELECT Col1,Col2 WHERE Col2='Total'",0),IFERROR(SEQUENCE(1,2)/0));IFERROR(QUERY({IMPORTRANGE("1IbPpoLLfa-ukoz2WInlgNGSNMNBxBwSx4in52fZCEyE" , "Sheet1!$a$1:$b")},"SELECT Col1,Col2 WHERE Col2='Yes'",0),IFERROR(SEQUENCE(1,2)/0))},"where Col1 is not null"))
I have multiple google sheets (45 of them, all dynamic, its content will keep on changing) and I want to combine data of all of them into a single file. I was hoping to use some importrange or QUERY function so that moment one / any file is updated, the changes reflect automatically on the combined sheet.
Example book 1 :
https://docs.google.com/spreadsheets/d/1sOkV9BT8ptndE0xcN2MUi4tTZ5p-aZxuLY_u29Y6nBI/edit?usp=sharing
Example book 2 :
https://docs.google.com/spreadsheets/d/1jZml9oVI2Flma407AB4ndl_ZIsQ_5I8zhkzvbL_EO_g/edit?usp=sharing
Example combined book :
https://docs.google.com/spreadsheets/d/1LkiIY1aUmwaouR7f4KhaGs6MV365KY7DYUPMiTzxjvc/edit?usp=sharing
first you need to connect them by pasting each IMPORTRANGE formula in some cell to get #REF! error
then hover over that #REF! error with your cursor and a secret magic button will popup
click on it to allow access
then you can stack up all import ranges and wrap them in a query:
=QUERY(
{IMPORTRANGE("ID1-or-URL1", "Sheet1!A1:A");
IMPORTRANGE("ID2-or-URL2", "Sheet1!A1:A");
IMPORTRANGE("ID3-or-URL3", "Sheet1!A1:A");
IMPORTRANGE("ID4-or-URL4", "Sheet1!A1:A")},
"where Col1 is not null"), 0)
update:
={ IMPORTRANGE("1sOkV9BT8ptndE0xcN2MUi4tTZ5p-aZxuLY_u29Y6nBI", "Sheet1!A1:N2");
QUERY({IMPORTRANGE("1sOkV9BT8ptndE0xcN2MUi4tTZ5p-aZxuLY_u29Y6nBI", "Sheet1!A3:N" );
IMPORTRANGE("19SFnJab9xVW2SenK-8IuG2cQRT2exJeyqARjTdDE_R8", "Sheet1!A3:N" )},
"where Col1 is not null", 0)}
I'm in the need of collecting unique values from a specific range in several sheets. Is it possible to combine functions in order to do this?
All sheets look the same regarding column structure.
As of now, my function collects from one sheet and it looks like this:
=unique(filter('Sheet1'!C4:C1000,'Sheet1'!C4:C1000<>""))
This collects unique values from Sheet1 from C4 to C1000 and excludes empty cells. This works awesomely, but I have more sheets that I'd like to merge values from. Any idea?
Basic idea is to combine data, first with help of {}:
= {sheet1C4:C1000;sheet2C4:C1000;sheet3C4:C1000}
The next step is to get rid of empty cells. To do it only once, use query:
= query({sheet1C4:C1000;sheet2C4:C1000;sheet3C4:C1000},
"select Col1 where Col1 <> ''")
And then grab uniques/ The final formula will look like:
= unique (query({sheet1C4:C1000;sheet2C4:C1000;sheet3C4:C1000},
"select Col1 where Col1 <> ''"))
By the way, query string may be shortened to this "where Col1 <> ''" will also work