I am building a reporting sheet that automatically extracts hours worked by person, date, and project from an aggregated sheet and transposes the data horizontally to a different spreadsheet.
The origin sheet looks like this:
The target sheet looks like this for each employee:
I am trying to figure out a function that extracts the relevant data from origin based on the name, project, and month values contained in row 2 of the target sheet. The origin sheet lists several more employees horizontally and several years vertically. I know I need the importrange function, but I am struggling with finding an extraction function based on the name, project, and day.
I would be very grateful for any suggestions :) Thanks in advance!
Try this series of formulas:
Output (D7):
=transpose(query({Sheet1!C3:C,indirect("Sheet1!"&address(3, Y3, 4)&":"&left(address(3, Y3, 4), 1))},
"select Col2 where
Col1 > date '"&text(date(C2, month(A2&1),), "yyyy-MM-dd")&"' and
Col1 < date '"&text(date(C2, month(A2&1) + 1, 1), "yyyy-MM-dd")&"'"))
I also added some formulas in other cells that are needed by the output, these are:
Y1 = match(L2, Sheet1!A1:1)
Y2 = if(L2 = query(transpose(Sheet1!1:1), "where Col1 is not null order by Col1 desc limit 1"),
counta(Sheet1!1:1)+countblank(Sheet1!1:1),
match(regexextract(join(",", Sheet1!1:1), L2&",*([^,]*),"), Sheet1!1:1))
Y3 = Y1 + match(P2, indirect("Sheet1!"&ADDRESS(2, Y1 + 1, 4)&":"&ADDRESS(2, Y2 - 1, 4)))
Output:
Related
My question was inspired by this post in that I'm wondering if it's possible to create a formula to stack a dynamic amount of arrays based on a list (see below for clarification).
Sample Starting Data From Three Sources
ID
Amount
India
9
Delta
4
Hotel
8
ID
Amount
Alpha
1
Echo
5
Foxtrot
6
ID
Amount
Bravo
2
Gulf
7
Charlie
3
Desired final result:
ID
Amount
Alpha
1
Bravo
2
Charlie
3
Delta
4
Echo
5
Foxtrot
6
Gulf
7
Hotel
8
India
9
I can get the final result by using a query function as shown in this spreadsheet with a formula referencing the appropriate cells with fileID and range:
=Query({IMPORTRANGE(E2,F2);
IMPORTRANGE(E3,F3);
IMPORTRANGE(E4,F4)},"Select * where Col1 is not null order by Col1",1)
if you want to play with it in your own sheet, you could use this hard-coded function which is the same as above:
=Query({IMPORTRANGE("1WtI56_9mhyArMn_j_H4pZg8E0QdIBaKoJfAr-fDAoE0","'Sheet1'!A:B");
IMPORTRANGE("1HamomAuLtwKJiFEtRKTuEkt--YDTtWChUavetBcAcBA","'Sheet1'!A2:B");
IMPORTRANGE("1WtI56_9mhyArMn_j_H4pZg8E0QdIBaKoJfAr-fDAoE0","'Sheet2'!A2:B")},"Select * where Col1 is not null order by Col1",1)
My Question:
Is there a way to leverage a formula to generate this result based on the number of file ids and ranges in columns E and F? So if a fourth ID and range were added, the desired result in columns a and b would be shown? I suspect Lambda would work, but I am not as strong with it as I should be.
Unsuccessful attempt:
=lambda(someIDs,SomeRanges,IMPORTRANGE(someIds,SomeRanges))(filter(E2:E,E2:E<>""),filter(F2:F,F2:F<>""))
REALLY Bad Attempts:
=contact(Player()*1800-CoffeeBribe*Not(Home))
=company(theMaster(emailed)*(false))<>🐇
All helpful answers will be upvoted if not accepted. Thanks.
if ranges would be the same:
=LAMBDA(x, QUERY(REDUCE({"ID", "Amount"}, x,
LAMBDA(a, c, {a; IMPORTRANGE(c, "Sheet1!A2:B")})),
"where Col1 is not null", 1))
(E2:INDEX(E:E, MAX((E:E<>"")*ROW(E:E))))
if ranges are not the same:
=INDEX(LAMBDA(x, y, QUERY(SPLIT(TRANSPOSE(SPLIT(QUERY(MAP(x, y,
LAMBDA(e, f, QUERY("♣"&FLATTEN(QUERY("♥"&TRANSPOSE(
IMPORTRANGE(e, f)),,9^9)),,9^9))),,9^9),
"♣")), "♥"), "where Col1 <> ' ' order by Col2", 1))(
E2:INDEX(E:E, MAX((E:E<>"")*ROW(E:E))),
F2:INDEX(F:F, MAX((F:F<>"")*ROW(F:F)))))
or:
=LAMBDA(x, QUERY(REDUCE({"ID", "Amount"}, x,
LAMBDA(a, b, {a; IMPORTRANGE(b, OFFSET(b,,1))})),
"where Col2 is not null", 1))
(E2:INDEX(E:E, MAX((E:E<>"")*ROW(E:E))))
in old days it would be solved by generating it:
={""; INDEX("={"&TEXTJOIN("; ", 1, "IMPORTRANGE("""&
FILTER(E2:E, E2:E<>"")&""", """&FILTER(F2:F, F2:F<>"")&""")")&"}")}
REDUCE accepts and returns arrays. We can use it to stack ranges. INDEX/COUNTA can be used to get the range needed without blanks. OFFSET can be used to get the next column's value.
=QUERY(
REDUCE(
{"Id","Amount"},
E2:INDEX(E2:E,COUNTA(E2:E)),
LAMBDA(
a,e,
{a;IMPORTRANGE(e,OFFSET(e,0,1))}
)
),
"Select * where Col1 is not null order by Col1",
1
)
I have the yellow table shown below, and I'm trying to get the blue table, which aggregates columns B:F by value, and then counts the number of 'x' symbols for each row value of column A.
Is there some basic SQL/array magic formula to get this, please? There must be.
Use this new functions formula
=BYROW(B2:4, LAMBDA(v, COUNTIF(v, "=x")))
Used:
BYROW, LAMBDA, COUNTIF
v is the array_or_range
Update
={ A2:A4, BYROW(B2:4, LAMBDA(vv, COUNTIF(vv, "=x")))}
For fun
Update 02
=ArrayFormula(TRANSPOSE(QUERY({
QUERY(TRANSPOSE(IF(A1:4<>"x",A1:4,1)),
" Select * Where Col1 is not null ", 1)},
" Select (Col1),sum(Col2),sum(Col3),sum(Col4) Group by Col1 ", 1)))
I have 2 sheets with values like :
Sheet 1, column D : SUPER iPhone X 16GB
Sheet 2, column B : iPhone X
I would like, in Sheet 1, to display the matching value from Sheet 2 (in this example "iPhone X")
I have tried many Vlookup like this but cannot find the right one :
=VLOOKUP("*"&D6&"*";Sheet 2!B:B;1;FALSE)
As requested I have created a sample spreadsheet with 2 sheets and sample data you can test here :
https://docs.google.com/spreadsheets/d/1OHsS5SyvzHvJaRtqKXVmCSSDeKA3iqX5JC2qE8WHPw0/edit?usp=sharing
Put it into B2
=ArrayFormula(QUERY(IF(ISERROR(FIND(LOWER('Feuille 2'!B:B);LOWER(A2)));;'Feuille 2'!B:B);"select Col1 where Col1 is not null limit 1";0))
try:
=VLOOKUP("*"&D6&"*"; 'Sheet 2'!B:B; 1; 0)
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 have a spreadsheet with 2 sheets in it,
I want to summarize the daily results by date.
I'm trying to use the query sum function to summarize everything since I wasn't able to do it with arrayformula.
but I'm not able to do it with a query as well.
I don't want to just copy-paste the sum function from each row to the next I want to just type the date I need in column A and get all the results in the different columns.
https://docs.google.com/spreadsheets/d/1ZsKXw32ycO_5KGD2I-Ug_GmqSIB_Z-D3Z1jlGd6fpTE/edit?usp=sharing
link to sheets.
getting the data from the database sheet.
I want to display the data-oriented by date and sumed.
for just 1 row you can simply do this and then drag down:
=ARRAYFORMULA(QUERY({TO_TEXT(DataBase!A:A), DataBase!B:E},
"select sum(Col5)
where Col1 = '"&TO_TEXT(A2)&"'
label sum(Col5)''", 0))
if array is needed then use:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A, QUERY(DataBase!A:E,
"select A,sum(E)
where A is not null
group by A
label sum(E)''", 0), 2, 0)))