I have the following data and I need to derive the max date (date and time) A for group B in google sheets.
A B
09/02/2023, 11:37:44 MARIO
09/02/2023, 11:42:41 MARIO
09/02/2023, 11:48:03 LUCA
09/02/2023, 13:03:06 LUCA
09/02/2023, 13:08:24 MARIO
09/02/2023, 13:15:57 LUCA
09/02/2023, 13:20:25 MARIO
09/02/2023, 13:23:38 MARIO
09/02/2023, 13:30:01 MARIO
09/02/2023, 13:33:36 LUCA
09/02/2023, 13:38:41 LUCA
09/02/2023, 13:41:38 LUCA
09/02/2023, 13:58:50 LUCA
09/02/2023, 14:04:57 LUCA
OUTPUT
09/02/2023, 13:30:01 MARIO
09/02/2023, 14:04:57 LUCA
=Query(Dati!A1:M,"Select B, Max(A) where B <> '' group by B label max(A) ''",0)
No MAX
Try to remove the commas before running the QUERY:
=ArrayFormula(Query({SUBSTITUTE(A1:A,",",),B1:B},"Select Col2, Max(Col1) where Col2 <> '' group by Col2 label max(Col1) ''",0))
Related
I need some help with google sheets lookup. I tried using VLOOKUP to do this, but wasn’t successful. I’m a google sheets beginner so need some help getting started.
I have 2 google sheets.
This is sheet1
Name
Emma
Kate
Tori
Rick
Jack
Topp
Brit
This is sheet2
Level1 Level2 Level3 State City
Brit Tori Kate Florida Orlando
Brit Tori Rick Alabama Gunther
Brit Topp Rick Texas Dallas
Jack Emma Rick Ohio Dayton
Jack Emma Rick Utah Puntin
Jack Emma Rick Maine Lunop
I want to add 2 columns to sheet1 so that it looks like this.
Name State City
Emma Ohio, Utah, Maine Dayton, Puntin, Lunop
Kate Florida Orlando
Tori Florida, Alabama, Texas Orlando, Gunther, Dallas
…and so on for the rest.
Rick
Jack
Topp
Brit
use:
=ARRAYFORMULA(IFNA(REGEXREPLACE({
VLOOKUP(A2:A, TRIM(SPLIT(FLATTEN(QUERY(QUERY(SPLIT(FLATTEN(
SEQUENCE(COUNTA(E2:E), COUNTA(E2:G))&"×"&E2:G&"♥×"&H2:H&","), "×"),
"select max(Col3) where Col2 is not null
group by Col1 pivot Col2"),,9^9)), "♥")), 2, 0),
VLOOKUP(A2:A, TRIM(SPLIT(FLATTEN(QUERY(QUERY(SPLIT(FLATTEN(
SEQUENCE(COUNTA(E2:E), COUNTA(E2:G))&"×"&E2:G&"♥×"&I2:I&","), "×"),
"select max(Col3) where Col2 is not null
group by Col1 pivot Col2"),,9^9)), "♥")), 2, 0)}, ",$", )))
For State column use-
=JOIN(", ",FILTER(Sheet2!D$2:D,MMULT(--(Sheet2!$A$2:$D=$A2),SEQUENCE(COLUMNS(Sheet2!$A$2:$D$2)))))
Then drag down and across as needed.
I have a spreadsheet that looks like this:
Dept
Process
Job No
Job Date
Job Time
a
x
123
18/7/22
12:00
a
w
123
18/7/22
13:00
a
y
123
19/7/22
10:00
b
z
456
18/7/22
14:00
and a formula from ExtendOffice
=ArrayFormula(QUERY(A1:A&{"",""},"select Col1, count(Col2) where Col1 != '' group by Col1 label count(Col2) 'Count'",1))
which gives
Dept
Count
a
3
b
1
As the formula counts the number of occurrences of a value in only one column, how should I modify it to include multiple columns? Say, including Job Date?
Job Date
Dept
Count
18/7/22
a
2
18/7/22
b
1
19/7/22
a
1
Thank you!
Try below QUERY() formula-
=QUERY(A1:E5,"select D, A, Count(A) group by D, A label Count(A) 'Count'",1)
I am trying to determine the number of quarters between two dates in google sheets with Q1 being Jan 1 2022 to March 31 2022 & so on for Q2, Q3, Q4.
For example: Date1: 06/14/2022 & Date2: 10/12/2022, the result should be 3 i.e., Q2, Q3, Q4.
Any advise on how this can be achieved.
I tried something like below but doesnt work
=CEILING(((YEAR(V3)*12+MONTH(V3))-(YEAR(U3)*12+MONTH(U3)))/3)
For a simple one in the same year, try
=int((month(V3)-1)/3)-int((month(U3)-1)/3)+1
or
=QUOTIENT(month(V3)-1,3)-quotient(month(U3)-1,3)+1
try:
=ARRAYFORMULA(TRANSPOSE(QUERY(QUERY(SPLIT(FLATTEN(ROW(A1:A10)&"×"&IFNA(VLOOKUP(
IF(SEQUENCE(1, 1000, 0)<=DAYS(B1:B10, A1:A10), A1:A10+SEQUENCE(1, 1000, 0), ),
SPLIT(FLATTEN({"1/1/", "1/4/", "1/7/", "1/10/"}&
SEQUENCE(4, 1, 2020)&"×"&{"Q1","Q2","Q3","Q4"}), "×"), 2, 1))), "×"),
"select max(Col2) where Col2 is not null group by Col2 pivot Col1"), "offset 1", 0)))
Name1 Name2 Name3 NameN
Lap1 1:20 1:30 1:19 1:40
Lap2 1:40 1:40 1:20 1:40
Lap3 1:30 1:19 1:22 1:20
LapN 1:19 1:21 1:20 1:19
I need to pull some statistics from a similar data set.
For example person with the most fastest laps, person with most 2nd fastest laps, etc.
I can't use a helper column.
Output In the format "NameN - count"
In this case the person with fastest laps would be "Name3 - 2 laps", 2nd fastest laps "Name1 - 2 laps" etc.
I tried adapting this formula I found from Excel but I can't make it work.
=LET(range,B2:E4,
nrows,ROWS(range),
ncols,COLUMNS(range),
ncells,COUNT(range),
races,INT(SEQUENCE(ncells,1,0)/ncols+1),
names,MOD(SEQUENCE(ncells,1,0),4)+1,
headers,B1:E1,
winners,SEQUENCE(nrows,1,1,ncols),
times,INDEX(range,races,names),
INDEX(headers,(MODE(INDEX(SORTBY(CHOOSE({1,2,3},races,names,times),races,1,times,1),winners,2)))))
first we find the fastest time per lap:
=INDEX(QUERY(SPLIT(FLATTEN(ROW(A2:A10)&"♦"&B2:E10), "♦"),
"select min(Col2) where Col2 is not null group by Col1 label min(Col2)''"))
next, we substitute times for names:
=ARRAYFORMULA(IF((B2:E10<>"")*(B2:E10=F2:F10), B1:E1, ))
and now we can count top players:
=QUERY(FLATTEN(G2:J10),
"select Col1,count(Col1)
where Col1 is not null
group by Col1
order by count(Col1) desc
label count(Col1)''")
all in one:
=INDEX(QUERY(FLATTEN(IFERROR(IF((B2:E10<>"")*(B2:E10=
QUERY(SPLIT(FLATTEN(ROW(A2:A10)&"♦"&B2:E10), "♦"),
"select min(Col2)
where Col2 is not null
group by Col1
label min(Col2)''")), B1:E1, ))),
"select Col1,count(Col1)
where Col1 is not null
group by Col1
order by count(Col1) desc
label count(Col1)''"))
and if you want you can add limit like this:
So I have a sheet like this
players:
and I need to get the sum of 4 highest scores of each team like this:
even when there are less than 4 players in a team (sum of 1, 2 or 3 best in these cases then) but without any scripts, I believe it's more than possible
try:
=ARRAYFORMULA({UNIQUE(SORT(FILTER(B2:B, B2:B<>""))),
MMULT(QUERY(SPLIT(TRANSPOSE(TRIM(QUERY(QUERY({9^9-C2:C&A2:A, B2:C},
"select max(Col3)
where Col2 !=''
group by Col1
pivot Col2"),,999^99))), " "),
"select Col2,Col3,Col4,Col5")*1, {1;1;1;1})})