Trying to make the products bought line up to the right edition number based on their SKUs and order in the sheet.
Right now, some emails don't show up (whether repeated in the purchase or almost randomly).
(The real data sheet has over 1000 purchases and 720 SKUs)
try:
=INDEX(IFNA(SPLIT(VLOOKUP(C2:C, TRIM(SPLIT(FLATTEN(QUERY(QUERY(
{'Tab02'!B2:B, 'Tab02'!A2:A&",", 'Tab02'!B2:B&"×"},
"select max(Col2) where Col1 is not null group by Col2 pivot Col3"),,9^9)),
"×")), 2, 0), ",")))
This formula in cell D1 on a tab called MK.Idea might work for you if i understand the question? It only needs Tab01 to work.
=ARRAYFORMULA(IFERROR(SPLIT({"Emails-->";VLOOKUP(C2:C,TRIM(SPLIT(TRANSPOSE(QUERY(QUERY('Tab01'!A:C&{"|","",""},"select MAX(Col3) group by Col3 pivot Col1"),,9^9)),"|")),2,0)}," ")))
Related
I made columns that simply lists all the schools for each student under a date column header. I only need to count the schools - I don't want to see any student data. I have a form that needs to be submitted to the state and there is a cell with the date we are submitting. I want to use an IMPORTRANGE to go to the other spreadsheet and find the column where the date matches the form date and pull back the count of schools in that column. I tried using INDEX/MATCH, etc., and while I have those working on the form for other data already on my spreadsheet - I can't seem to get them to work on the 'outside' spreadsheet. Any help is appreciated! I'm attaching an example spreadsheet with more explanation. I hope it's clear. Thank you.
Example Document
ztiaa has provided a good solution. I will suggest another which pivots the data differently. I feel that having the dates go across columns is going to quickly become unwieldy. So this approach leaves the dates running down the right side with the schools running as column headers. My solution also includes exceptions such as snow days, as those will likely be important to see at a glance as well. Just be careful to use the same notation for such exceptions. For instance, always use "snowday" (not, eg., "snow day") or "prep day" (not, e.g., "prep").
In Sheet1, use IMPORTRANGE to bring in the data exactly as you have it listed in your sample sheet (i.e., dates at top, school names or exceptions under each date header).
Then, in a new sheet, place the following formula in cell A1:
=ArrayFormula({QUERY(SPLIT(FLATTEN(FILTER(Sheet1!1:1&"~"&INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A)),Sheet1!1:1<>"")),"~",1,0),"Select Col1, COUNT(Col1) WHERE Col2 Is Not Null GROUP BY Col1 PIVOT Col2 FORMAT Col1 'mmm dd'"),TRANSPOSE({"District Totals",MMULT(SEQUENCE(1,ROWS(Sheet1!A2:A),1,0),IF(FILTER(INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A)),Sheet1!1:1<>"")="",0,1))})})
This assumes that the first sheet is, in fact, named Sheet1. If it is not, you'll need to change every instance of that sheet name in the formula.
It will probably further aid visual ease if you freeze Row 1 and Column 1 (View > Freeze > 1 row / 1 column).
ADDENDUM (after seeing realistic copy of OP's sheet)
=ArrayFormula({TRANSPOSE(QUERY(SPLIT(FLATTEN(FILTER(Sheet1!1:1&"~"&INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A)),Sheet1!2:2<>"")),"~",1,0),"Select Col1, COUNT(Col1) WHERE Col2 Is Not Null GROUP BY Col1 PIVOT Col2 FORMAT Col1 'mmm dd'"));{"District Totals",MMULT(SEQUENCE(1,ROWS(Sheet1!A2:A),1,0),IF(FILTER(INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A)),Sheet1!2:2<>"")<>"",1,0))}})
If you prefer to see the name of the exception (e.g., "snowday") rather than the count of 1 for each exception in the "District totals" line:
=ArrayFormula({TRANSPOSE(QUERY(SPLIT(FLATTEN(FILTER(Sheet1!1:1&"~"&INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A)),Sheet1!2:2<>"")),"~",1,0),"Select Col1, COUNT(Col1) WHERE Col2 Is Not Null GROUP BY Col1 PIVOT Col2 FORMAT Col1 'mmm dd'"));{"District Totals",IF(MMULT(SEQUENCE(1,ROWS(Sheet1!A2:A),1,0),IF(FILTER(INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A)),Sheet1!2:2<>"")<>"",1,0))=1,FILTER(Sheet1!2:2,Sheet1!2:2<>""),MMULT(SEQUENCE(1,ROWS(Sheet1!A2:A),1,0),IF(FILTER(INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A)),Sheet1!2:2<>"")<>"",1,0)))}})
If you want exceptions (e.g., "snowday") to always appear at the bottom instead of in alphabetical order within the school-name list:
=ArrayFormula({TRANSPOSE(QUERY(SPLIT(FLATTEN(FILTER(Sheet1!1:1&"~"&IF(REGEXMATCH(UPPER(INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A))),INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A))),,"‡")&INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A)),Sheet1!2:2<>"")),"~",1,0),"Select Col1, COUNT(Col1) WHERE Col2 Is Not Null AND Col2 <> '‡' GROUP BY Col1 PIVOT Col2 FORMAT Col1 'mmm dd'"));{"District Totals",IF(MMULT(SEQUENCE(1,ROWS(Sheet1!A2:A),1,0),IF(FILTER(INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A)),Sheet1!2:2<>"")<>"",1,0))=1,FILTER(Sheet1!2:2,Sheet1!2:2<>""),MMULT(SEQUENCE(1,ROWS(Sheet1!A2:A),1,0),IF(FILTER(INDIRECT("Sheet1!2:"&ROWS(Sheet1!A:A)),Sheet1!2:2<>"")<>"",1,0)))}})
Try this out
=ArrayFormula({query(split(flatten(text(A1:E1,"mmm/d")&"❄️"&A2:E),"❄️"),"select Col2, count(Col2) where not Col2 matches '|Snowday' group by Col2 pivot Col1");{"District Total",transpose(MMult(transpose(N(filter(A2:E,not(RegexMatch(A2:E2,"Snowday")))<>"")),sequence(rows(A2:E))^0))}})
I am designing a formula to warn the time of work shifts of the same employee conflicting. Based on the working schedule on A row to arrange the work shifts of every employee. The general working time is 3 hours. For an example of a picture, Andy in the table has arranged a shift at 2021/10/23 22:00, however, accidentally arranges andy works again at 2021/10/24 01:45, and his previous three hours work times have not been completed, which conflicts, so I hope to design that when his name is marked in the B row, it will be marked as a reminder. According to the picture, I originally designed an index and Match function in the D row to catch The names of employees with conflicting working hours are distinguished by V and X, but it seems that this group of functions cannot be successful. I would like to ask if there is a correct solution to solve it, thank you for your assistance.
add helper column:
=INDEX(IF(B:B="",,REGEXMATCH(B:B&COUNTIFS(B:B, B:B, ROW(B:B), "<="&ROW(B:B)),
TEXTJOIN("|", 1, "×", IF(0.125>IFNA(ABS(QUERY(
TRANSPOSE(SPLIT(FLATTEN(QUERY(QUERY(QUERY({1*A:A, B:B},
"select max(Col1) where Col2 is not null group by Col1 pivot Col2"),
"offset 1", ),,9^9)), " ")), "offset 1", )-
TRANSPOSE(SPLIT(FLATTEN(QUERY(QUERY(QUERY({1*A:A, B:B},
"select max(Col1) where Col2 is not null group by Col1 pivot Col2"),
"offset 1", ),,9^9)), " "))), 99), TRANSPOSE(SORT(UNIQUE(B:B)))&ROW(A:A)+1, )))))
you can change ranges to fit your needs just dont change last ROW(A:A)+1
I have list of assets
There is information about buy date and buy value
there is information about depreciation year
I want to make the year of each deprecation and the depreciation value, be described yearly from top to down automatically
I prefer array formula to prevent me from dragging the formula every now and then
here is the link of the case:
https://docs.google.com/spreadsheets/d/1wJ65_Q3bD1Fz_ueW2cmQP_L03r8U2jvbMXstzzjMDb8/edit#gid=0
yellow cells are raw data
green cells are expected form of output
thankyou in advance!
try:
=ARRAYFORMULA(SPLIT(FLATTEN(QUERY(TRANSPOSE(QUERY({(SPLIT(QUERY(FLATTEN(IFERROR(SPLIT(
REPT(A2:A&"×♦"&TEXT(B2:B, "d mmm")&"×"&YEAR(B2:B)&"×♦"&D2:D/C2:C&"¤", C2:C), "¤"))),
"where Col1 is not null"), "×")), COUNTIFS(
SPLIT(QUERY(FLATTEN(IFERROR(SPLIT(REPT(B2:B&"¤", C2:C), "¤"))),
"where Col1 is not null"), "×"),
SPLIT(QUERY(FLATTEN(IFERROR(SPLIT(REPT(B2:B&"¤", C2:C), "¤"))),
"where Col1 is not null"), "×"), SEQUENCE(SUM(C2:C)), "<="&SEQUENCE(SUM(C2:C)))},
"select Col1,Col2,Col3+Col5,Col4 label Col3+Col5''")),,9^9)), "♦"))
I am trying to use a Google Sheet to monitor the loan of inventory IN and OUT. There are several item numbers involved. There are two named ranges: ITEMIN and ITEMOUT. I tried using this formula:
=IF(ISBLANK(ITEMOUT),"--N/A--", IF(COUNTIF(ITEMIN, ITEMOUT)=0,"IN", "OUT"))
but it only registers correctly for the first cycle. Subsequent loan outs will be registered as IN. I have then tried this formula:
=IF(ISBLANK(ITEMOUT),"--N/A--", IF(ISODD(COUNTIF(ITEMIN,ITEMOUT)), "IN", "OUT"))
I tried to capture the ODD and EVEN occurrences of the item numbers to register the OUT and IN. For example: 1 occurrence (odd) of item no. 168 = OUT, 2 occurrences (even) of item no. 168 = IN and so on. The latter formula registered the OUT and IN in the following order for a particular item number: OUT->IN->IN->OUT->OUT->IN->IN instead of OUT->IN->OUT->IN
Really hope someone can help me with this as I am not really proficient in formulas or scripts.
Thank you in advance.
Actual worksheet:
Desired worksheet:
*NOTE: Attention to the item number 160 for both images.
based on your sheet this is the IN/OUT:
=ARRAYFORMULA({QUERY(SPLIT(FLATTEN({
IF('CHECK OUT'!C2:H="",,'CHECK OUT'!A2:A&"×"&'CHECK OUT'!B2:B&"♦"&'CHECK OUT'!C2:H);
IF('CHECK IN'!C2:H="" ,,'CHECK IN'!A2:A &"×"&'CHECK IN'!B2:B &"♦"&'CHECK IN'!C2:H)}), "×"),
"select Col2 where Col2 is not null order by Col1"), IF(ISODD(COUNTIFS(QUERY(SPLIT(FLATTEN({
IF('CHECK OUT'!C2:H="",,'CHECK OUT'!A2:A&"×"&'CHECK OUT'!B2:B&"♦"&'CHECK OUT'!C2:H);
IF('CHECK IN'!C2:H="" ,,'CHECK IN'!A2:A &"×"&'CHECK IN'!B2:B &"♦"&'CHECK IN'!C2:H)}), "×"),
"select Col2 where Col2 is not null order by Col1"), QUERY(SPLIT(FLATTEN({
IF('CHECK OUT'!C2:H="",,'CHECK OUT'!A2:A&"×"&'CHECK OUT'!B2:B&"♦"&'CHECK OUT'!C2:H);
IF('CHECK IN'!C2:H="" ,,'CHECK IN'!A2:A &"×"&'CHECK IN'!B2:B &"♦"&'CHECK IN'!C2:H)}), "×"),
"select Col2 where Col2 is not null order by Col1"),
SEQUENCE(COUNTIF({'CHECK OUT'!C2:H; 'CHECK IN'!C2:H}, "<>")), "<="&
SEQUENCE(COUNTIF({'CHECK OUT'!C2:H; 'CHECK IN'!C2:H}, "<>")))), "IN", "OUT")})
I have a list of data on one sheet. A second sheet is used to display who's done what, like a dashboard. I've been given an array formula to generate the data that looks up the employee's name, and displays it if they are present on the list for a course completed. If so, a "yes" is listed on the dashboard under the corresponding course number. I cannot figure out what I need to change the REGEXREPLACE with to present the date column from the data list instead of "yes". I'm aware REGEXREPLACE only works for text values, and dates aren't - even changing the date column to text seems to matter not.
Here is a working example of the current array formula:
https://docs.google.com/spreadsheets/d/1jkG515zyl4UxRHxhtFTjgWsjG0aBE4vsOxbpvqgjogU/edit#gid=536376041
Here is the formula used:
=ARRAYFORMULA(IF(A5:A="",,REGEXREPLACE(IFNA(VLOOKUP(A5:A,
QUERY({TRIM('Form Responses 1'!B2:G)}, "select Col1,count(Col1) group by Col1 pivot Col6"), MATCH(F2:P2,
QUERY(QUERY({TRIM('Form Responses 1'!B2:G)}, "select Col1,count(Col1) group by Col1 pivot Col6"), "limit 0", 1), 0), 0))&"", "\d+", "yes")))
In the above example, I need the Date Completed from col D on the Form Responses sheet.
Here is a first attempt that might help you.
This is a straightforward query, that pulls the dates, and pivots to have the employee names on the left, and the course names on the top.
But it doesn't try to match up data with an existing list of employees - it just lists all of the employees that have submitted a form. So if you want to see all employees, with blank rows for those who haven't submitted a form, this won't work for you.
The formula, in A2,is:
=ARRAYFORMULA(QUERY({'Form Responses 1'!B2:G}, "select Col1,max(Col3) where Col1<>'' group by Col1 pivot Col6 order by Col1"))
See tab Sheet1-GK, added to your sample sheet.
Let me know if this helps, or if you need something different.
UPDATE:
To limit the result to a specific list of courses, use the following modification:
=ARRAYFORMULA(QUERY({'Form Responses 1'!B2:G},
"select Col1,max(Col3) where Col1<>''
and Col6 matches '" & TEXTJOIN("|",1,F2:2) & "'
group by Col1 pivot Col6 order by Col1 "))
Here, the list of desired courses to report on is in F2:2, where you had them originally, but this list could be kept anywhere, even on another tab. If you name the range where you place it, that can simplify this formula a bit. For now, you could just hide row 2. I've grouped it, on the left, to hide it. Use the [+] to reveal it again.