Related
I have a master sheet that contains all of the data for other sheets. Column A in the master sheet is the name for who's sheet it will import to. So if the name is "John" then every row that has "John" in column A from the master sheet will be imported into John's sheet. I have the person's name in cell G1 of their own respective sheet and use the following formula.
=ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("LINK_TO_SHEET","Assignments!A2:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1='"&G1&"'",0),""))
Master sheet looks like this:
Assigned To
Name
State
City
John
Blake G.
Arizona
Phoenix
Andy
Chase C.
Arizona
Phoenix
John
Amy B.
New Mexico
Santa Fe
John
Bill S.
Texas
Austin
John's sheet will look like this:
Name
State
City
Blake G.
Arizona
Phoenix
Amy B.
New Mexico
Santa Fe
Bill
Texas
Austin
I want to separate the data based on what is in Col17 and put a single word between the two data sets. Col17 has either a Y or a N so I can just add AND Col17='N' to the existing formula. I double up the formula, but changed the last condition to be Col17='Y' so that I can pull the two data sets separately and on top of each other.
={ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("LINK_TO_SHEET","Assignments!A2:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1='"&G1&"' AND Col17='N'",0),""));ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("LINK_TO_SHEET","Assignments!A2:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1='"&G1&"' AND Col17='Y'",0),""))}
What I want to do is add a single word between the two imported sets of data. It should like kinda like this:
Name
State
City
Blake G.
Arizona
Phoenix
Amy B.
New Mexico
Santa Fe
Inactive
Bill
Texas
Austin
I added the word inactive so the middle looks like ""));"Inactive";ARRAY between the two formulas but because of how Query works I get an error saying the array lengths for each formula do not match. Is there alternative to help make this happen or will I need to figure out a workaround with something that isn't Query?
SUGGESTION
Feel free to comment below if ever your question has been misunderstood.
In my understanding, here's your process:
The first formula will list all data that has N value in Col17 .
The second formula will list all data that has Y value in Col17.
This second formula should also have an Inactive title header.
Merge the two formulas separated by the word "Inactive".
If I got it correctly, you could use the label clause to add "Inactive" in your second Query function as seen on this tweaked formula:
={ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("SHEET_URL","A1:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1 = '"&G1&"' AND Col17 = 'Y'"),0));ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("SHEET_URL","A1:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1 = '"&G1&"' AND Col17 = 'N' label Col2 'Inactive'"),0))}
Demo
Sample result.
E.g. If there's new data added that should be under "Inactive".
Main Sheet
John's Sheet
#SputnikDrunk2 is a very good workaround. Just in case you decide to stack different types of ranges that are not queries, you should consider that they need to have the same amount of columns. So if you add a new row it should have the 12 columns you have from your Queries. One way would be like this:
={ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("LINK_TO_SHEET","Assignments!A2:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1='"&G1&"' AND Col17='N'",0),""));
{"Inactive","","","","","","","","","","",""};
ARRAYFORMULA(IFNA(QUERY(IMPORTRANGE("LINK_TO_SHEET","Assignments!A2:Q"),"SELECT Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13 WHERE Col1='"&G1&"' AND Col17='Y'",0),""))}
Another option to avoid creating so many "","","","" is to use this "trick" that divides a range by 0, and with IFERROR it returns empty cells:
{"Inactive",INDEX (IFERROR(SEQUENCE(1,11)/0,))};
Here's another approach:
=lambda(z,
{filter(choosecols(z,2,3,4,5,6,7,8,9,10,11,12,13),index(z,,1)=A1,index(z,,17)="N");
{"Inactive",makearray(1,11,lambda(r,c,iferror(1/0)))};
filter(choosecols(z,2,3,4,5,6,7,8,9,10,11,12,13),index(z,,1)=A1,index(z,,17)="Y")}
)(A1:Q4)
A1:Q4 part in the formula should be replaced with your importrange Fx
2,3,4,5,6,7,8,9,10,11,12,13 part can also be replaced with shorter sequence(1,12,2,1)
first time posting here!
I have the following scenario:
1 Google Sheet with information sorted in tables (Master Data)
1 Google Sheet that =Importrange the data from the Master Data Google Sheet.
I need to import one time, or multiple times, some of the rows that are Imported from the Master Data based on the following criteria:
On the Master Data Google Sheet, a column would be present, showing in which Country/Countries the student lives. If the student lives 1 country, import the row once. If it is in 2,3,4... countries, import the same row it 2,3,4... times.
Right now, I am using the following formula:
=QUERY({IMPORTRANGE(Reference!A8,Reference!$A$2&Reference!B6)},"select Col6 where Col10='"&'Advanced Settings'!B5&"'")
This formula Imports from the Master Data file (Reference!A8), a particular tab (Reference!$A$2) and a particular range in this tab Reference!B6. Finally, it filters the data imported (only the 6th Col of the range, and only if on Col 10 the row has a particular value (Advanced Settings'!B5).
Is there a way to Import the name of the student as many times as countries they live in inside the same Array formula?
Right now, I am just adding more importrange (if there are 3 countries, I will add Importrange three times) with filters, but I would like to make it dynamic for the number of countries, without manual input every time. Also, the number of students imported varies every time so I can't look manually at the number of rows and then add a formula after the last cell of the array formula.
Thanks!
EDIT:
Sample Data and expected result:
Sample Data
Student Name
Gender
Class Level
Home State
Country
Alexandra
Female
4. Senior
CA
UK, US
Andrew
Male
1. Freshman
SD
UK
Anna
Female
1. Freshman
NC
UK, US
Becky
Female
4. Senior
SD
US
Benjamin
Male
4. Senior
WI
UK
Filter on both Class Level (4. Senior) and Country
Name
Reason for appearing (explanation for you)
Alexandra
Appears because Alexandra is Senior, UK
Alexandra
Appears because Alexandra is Senior, US
Becky
Appears because Becky is Senior, US
Benjamin
Appears because Benjamin is Senior, UK
The expected result here is that Alexandra appears twice as she's Senior and both US and UK.
if Reference!B6 is a range and IMPORTRANGE for each country is the same try:
=QUERY({IMPORTRANGE(Reference!A8, Reference!A2&Reference!B6)},
"select Col6
where Col10 matches '"&TEXTJOIN("|", 1, 'Advanced Settings'!B5:B)&"'", )
IF C = Senior and E is splittable, create a array of corresponding As. Then, FLATTEN the array and REDUCE to remove all empty items in the array.
Sample:
=ARRAYFORMULA(
REDUCE(
"Senior List",
FLATTEN(
IF(
C2:C6="4. Senior",
IF(ISTEXT(SPLIT(E2:E6,",")),A2:A6,),
)
),
LAMBDA(a,c,IF(c="",a,{a;c}))
)
)
The formula has to be input on cell A2. The logic should be that the formula would result in the following cell (from cell A3 downwards) outputting a no. in a reversed numbered list format in column 1. And for those who are "Resigned" or "Dismissed" in column 3, the formula would skip them and the next numbering would be a follow-up from the previous no. instead.
We're using in-house software that's similar to Google Sheets and Microsoft Excel so certain functions/formulas like REGEX and custom functions are not supported.
No.
Name
Employment status
(insert formula here
Sample Name
Type of Employment
5
John
Full-time
Mary
Resigned
4
Jack
Part-time
3
Tim
Contract
Jane
Dismissed
2
Jonathan
Full-time
1
Larry
Part-time
This post is a repost from this ask as the solutions weren't applicable to this issue, unfortunately. So I'm looking for alternative solutions from those answers.
Alternative:
=ARRAYFORMULA(IF(MMULT(N(C2:C8={"Resigned","Dismissed"}),{1;1}),"",MMULT(N(ROW(C2:C8)<=TRANSPOSE(ROW(C2:C8))),1-ISNUMBER(MATCH(C2:C8,{"Resigned","Dismissed"},0)))))
Note that the oft-seen technique of replacing the upper cell reference in the range passed with a reference to the entire column (for example, C2:C) would here not be advisable. If such flexibility is required, suggest you create a dynamic Named Range.
can't be simpler:
=ARRAYFORMULA(IF((C2:C="contract")+(C2:C="part-time")+(C2:C="full-time"),
COUNTIFS(SUBSTITUTE(C2:C, "Contract", "time"), "*time", ROW(C2:C), ">="&ROW(C2:C)), ))
Paste this formula in A2
= {"Count" ; ArrayFormula(IFNA(IF(B3:B="",,VLOOKUP(B3:B, FILTER({ B3:C, SEQUENCE(ROWS(B3:B),1,COUNTA(B3:B),-1) }, C3:C<>"Resigned",C3:C<>"Dismissed"),3,0)),""))}
I have a table with names of performers and the activities they performed in which cities. Now, I am trying to find out who all performed in which city using filter formula - Check C15 in below sheet.
https://docs.google.com/spreadsheets/d/19U0vjtABXQ-MltxZoW7v0vjt1L6gM2Lc2VP3Z-BuKwE/edit?usp=sharing
The formula I am trying to use is:
=join(", ",transpose(iferror(filter(A2:A11,REGEXMATCH(C2:G11,"Chicago")))))
If I change G11 to C11 in above formula, I can see some output which is incorrect.
(a) I want the names of performers who performed in Chicago from columns C all the way to G.
(b) Even if I keep it as C11, it gives the name of only the first performer.. and not all those who performed in Chicago in column C
For just Chicago, the output should be:
Nils, Tom in F15
Nils, Tom, Jack, Amanda, Sam in C15
Any help will be greatly appreciated.
=join(", ",transpose(iferror(filter(A2:A11,REGEXMATCH(B2:B11,"Chicago")))))
works for me and I get Nils,Tom in F15.
One way of getting the matches in all columns is to get the row totals like this, and where they aren't zero to join the values in the first column:
=ArrayFormula(textjoin(",",true,if(mmult(n(regexmatch(B$2:G$11,A15)),transpose(column(B:G))),A$2:A$11,)))
You could use something like this:
=join(", ",transpose(filter(A2:A11,REGEXMATCH(C2:C11&D2:D11&E2:E11&F2:F11&G2:G11,"Chicago"))))
sample attendance (google) sheet
I want count the number of total lates per student name on this sample sheet, e.g, how many lates Mary Love has (actual sheet has over 30,000 rows, 10 columns). If possible, this count needs to change as students have additional lates. I'd really appreciate any help someone might be able to provide. I thank you very much in advance.
In addition to previous post, a QUERY() function also seems a good option as it can output a 2D-array, containing the names and the counts in one formula (no need to drag down). As an example, try:
=query(A:G, "select A, count(B) where B ='Late' group by A ", 1)
If you want to limit the result tho those who had more then 3 late's, you can do:
=query(query(A:G, "select A, count(B) where B ='Late' group by A ", 1), "where Col2 > 3")
Also further filtering with date can be done very easily. However I think that may require some 'cleaning up' of the current data: I noticed a lot of different date formats in col D... :-)
For counting each of several students and to allow greater versatility I suggest a pivot table with Student Name for Rows, Late for Values with Summarise by: COUNTA and Late for Filter with Show: Late.
You can use the COUNTIFS function to get what you are looking for. This formula will count all matches for multiple criteria ranges and criteria (e.g. student name & late).
This is the syntax for the formula:
COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…)
If you put Mary Love in cell I2, you could then put this in J2.
=countifs(B:B,"=late", A:A,I2)
Then as more rows are added it will automatically update the "lates". I would also suggest using named ranges, then you could replace B:B and A:A with the named range.
I would suggest using the =query function as documented below. If that doesn't meet your needs you could modify the above:
=if (countifs(B:B,"=Late", A:A,I2, D:D, ">="&N2) >= 3, "True", "False")
This will put "True" in the column if there are 3 or more lates, false if not. This will require you put the date you want to check against in column N2. Change N2 above if you want to use a different column.