Google Sheets Query across sheets using checkboxes to limit results - if-statement
I am making a mini-search engine in Google Sheets. I have information in 3 sheets (6th Grade, 7th Grade, 8th Grade).
In the past, I had a Combined sheet that combined the information from each sheet. However, as I add additional sheets for grades 1-5, the amount of information returned will be excessive. I want to allow the user to use checkboxes to identify which grades they want results from.
Here is the workbook.
I've added sheets for all the grades by copying the data from 6th, 7th, and 8th. The format of the data will be the same once I get my hands on it.
Here is the formula I've been playing around with:
=iferror(If(D2=True,Query(
Kindergarten!A:I,"Select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0",
),
Query(
{Kindergarten!A:I;'1st'!A:I;'2nd'!A:I},"Select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0",
),
"No Matches, try a different search"))
you did not mention what you want to search in Search cell, but the formula would be:
=IFERROR(QUERY({
IF(D2=TRUE, IFERROR(QUERY({Kindergarten!A:I}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0", 0), {"","","","","","","",""}), {"","","","","","","",""});
IF(E2=TRUE, IFERROR(QUERY({'1st'!A:I}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0", 0), {"","","","","","","",""}), {"","","","","","","",""});
IF(F2=TRUE, IFERROR(QUERY({'2nd'!A:I}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0", 0), {"","","","","","","",""}), {"","","","","","","",""});
IF(G2=TRUE, IFERROR(QUERY({'3rd'!A:I}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0", 0), {"","","","","","","",""}), {"","","","","","","",""});
IF(H2=TRUE, IFERROR(QUERY({'4th'!A:I}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0", 0), {"","","","","","","",""}), {"","","","","","","",""});
IF(C4=TRUE, IFERROR(QUERY({'5th'!A:I}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0", 0), {"","","","","","","",""}), {"","","","","","","",""});
IF(D4=TRUE, IFERROR(QUERY({'6th'!A:I}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0", 0), {"","","","","","","",""}), {"","","","","","","",""});
IF(E4=TRUE, IFERROR(QUERY({'7th'!A:I}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0", 0), {"","","","","","","",""}), {"","","","","","","",""});
IF(F4=TRUE, IFERROR(QUERY({'8th'!A:I}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0", 0), {"","","","","","","",""}), {"","","","","","","",""});
IF(G4=TRUE, IFERROR(QUERY({'9th and 10th'!A:I}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0", 0), {"","","","","","","",""}), {"","","","","","","",""});
IF(H4=TRUE, IFERROR(QUERY({'11th and 12th'!A:I}, "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8 where Col9>0", 0), {"","","","","","","",""}), {"","","","","","","",""})},
"where Col1 is not null", 0), "No Matches, try a different search")
Related
How to write single query with TOPNSKIP, DATESBETWEEN, and FILTERS in DAX?
Execute following DAX functions in single query. TOPNSKIP DATESBETWEEN FILTER/FILTERS where I can do a query with TOPNSKIP with FILTER/FILTERS, it worked and returns data EVALUATE TOPNSKIP (10, 10, FILTER(Sales,Sales[Name] = "computer") ) ORDER BY 'Sales'[PurchasedDate] ASC It return all rows where Name="computer" But when try following two queries first one is working if SKIP value 0 EVALUATE TOPNSKIP (10, 0, SUMMARIZECOLUMNS ( 'Sales'[Name],'Sales'[PurchasedDate],DATESBETWEEN ('Sales'[PurchasedDate], DATE(2022, 01, 01) , DATE(2022, 02, 01)), FILTER(Sales,Sales[Name] = "computer") ) ) ORDER BY 'Sales'[PurchasedDate] DESC It returns data for the 2 columns When I execute following query if skip=10, query failed to execute EVALUATE TOPNSKIP (10, 10, SUMMARIZECOLUMNS ( 'Sales'[Name],'Sales'[PurchasedDate],DATESBETWEEN ('Sales'[PurchasedDate], DATE(2022, 01, 01) , DATE(2022, 02, 01)), FILTER(Sales,Sales[Name] = "computer") ) ) ORDER BY 'Sales'[PurchasedDate] DESC Error: TOPNSKIP is not supported with the given parameter combination. Please review MSDN documentation.
Issue has been resolved with following query EVALUATE CALCULATETABLE ( TOPNSKIP( 10, 10, 'Sales', 'Sales'[PurchasedDate], DESC ) ,FILTER(Sales,Sales[Name] = "Computer") ,DATESBETWEEN ('Sales'[PurchasedDate], DATE(2021, 01, 01) , DATE(2022, 01, 31)) )
VLOOKUP inside an ARRAY to search another Google Sheets book
I have a document 'A' where I have a formula in a 'SEARCH' tab to search for a value from another 'ENTRIES' tab in Google Sheets based on a cell reference written by the user in the same 'SEARCH' tab than the formula. If I duplicate the 'SEARCH' tab in another Google sheets document/book 'B', how should the formula be altered so that it still references 'A'? The original formula is based on: Search a value from another tab/sheet in google sheets based on cell reference WORKING EXAMPLE HERE (This would be document 'B' and it tries to reference a search in another document 'A'): https://docs.google.com/spreadsheets/d/1Ffl6IbehI0slLChyuW-MDezF2xwt0rX12JNIaCFvEI8/edit?usp=sharing (You can see in cell B8 the formula with IMPORTRANGE that I'm trying to implement) And this would be document'A'. Originally it is an example of how to search for values in another tab based in a different cell reference : [https://docs.google.com/spreadsheets/d/1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8/edit?usp=sharing] I also checked: Google Sheets VLOOKUP of multiple columns across multiple sheets VLOOKUP to the left from another sheet in Google Sheets Docs Editors help: IMPORTRANGE https://support.google.com/docs/answer/3093340 My original formula in book 'A' is: =IFERROR(ARRAYFORMULA( IF(B3<>"",SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(B3, {data!AN:AN, data!A:BN}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), IF(C3<>"", SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(C3, {data!AK:AK, data!A:BN}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), IF(E3<>"", SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(E3, {data!BJ:BJ, data!A:BN}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), IF(D3<>"", SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(D3, {data!R:R, data!A:BN}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), ))))), "no match found") I was trying to use : VLOOKUP(search_key, importrange, index, [is_sorted]) to get in an IMPORTRANGE, like: IFERROR(ARRAYFORMULA( IF(B3<>"", SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(B3, {(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8/edit#gid=468700626","data!AN:AN"), (IMPORTRANGE("https://docs.google.com/spreadsheets/d/1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8/edit#gid=468700626","data!A:BN")}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), IF(C3<>"", SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(C3, {(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8/edit#gid=468700626","data!AK:AK"), (IMPORTRANGE("https://docs.google.com/spreadsheets/d/1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8/edit#gid=468700626","data!A:BN")}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), IF(E3<>"", SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(E3, {(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8/edit#gid=468700626","data!BJ:BJ"), (IMPORTRANGE("https://docs.google.com/spreadsheets/d/1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8/edit#gid=468700626","data!A:BN")}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), IF(D3<>"", SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(D3, {(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8/edit#gid=468700626","data!R:R"), (IMPORTRANGE("https://docs.google.com/spreadsheets/d/1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8/edit#gid=468700626","data!A:BN")}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), ))))), "no match found"))))))))) It marks as ERROR, but even if I change it to be ... VLOOKUP(B3{(IMPORTRANGE("URL","data!R:R"),(IMPORTRANGE("URL","data!A:BN")}, ... that gets into () both references, it still marks ERROR.
Pharse Error is caused by extra parenthesis which breaks the formula. FX should be: =IFERROR(ARRAYFORMULA( IF(B3<>"", SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(B3, {IMPORTRANGE("1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8","data!AN:AN"), IMPORTRANGE("1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8","data!A:BN")}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), IF(C3<>"", SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(C3, {IMPORTRANGE("1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8","data!AK:AK"), IMPORTRANGE("1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8","data!A:BN")}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), IF(E3<>"", SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(E3, {IMPORTRANGE("1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8","data!BJ:BJ"), IMPORTRANGE("1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8","data!A:BN")}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), IF(D3<>"", SUBSTITUTE(TRANSPOSE(SPLIT(TEXTJOIN(CHAR(10)&"♦"&CHAR(10)&"♦", 1, VLOOKUP(D3, {IMPORTRANGE("1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8","data!R:R"), IMPORTRANGE("1qLcJdCn4EdV7lPOAfZ_CMak1LBkve45FL5SXyqBV3L8","data!A:BN")}, {41,38,19,11,55,56}, 0)), CHAR(10))), "♦", ), ))))), "no match found")
How to combine the code of two array queries in Google Sheets
I need to combine two queries that are both inside arrayformulas so that I just have one query: I've tried using Union First Code: = ARRAYFORMULA(QUERY({MID(Sheet1!B1:B, 8, 5), Sheet1!A1:AS}, "select count(Col13) where Col13>=0 group by Col1 label count(Col13)'Winners #'")) Second Code: = ARRAYFORMULA(QUERY({MID(Sheet1!B1:B, 8, 5), Sheet1!A1:AS}, "select count(Col13) where Col13<=0 group by Col1 label count(Col13)'Losers #'"))
=ARRAYFORMULA(QUERY(REGEXREPLACE(TO_TEXT(QUERY({ QUERY({MONTH(MID('grouping project'!A2:A, 8, 3)&1)&"♦"& MID('grouping project'!A2:A, 8, 5), 'grouping project'!A2:AO}, "select Col1,count(Col3),'Winners #' where Col1 is not null and Col3 >= 0 group by Col1 label count(Col3)'','Winners #'''", 0); QUERY({MONTH(MID('grouping project'!A2:A, 8, 3)&1)&"♦"& MID('grouping project'!A2:A, 8, 5), 'grouping project'!A2:AO}, "select Col1,count(Col3),'Loosers #' where Col3 <= 0 and Col1 is not null group by Col1 label count(Col3)'','Loosers #'''", 0)}, "select Col1,sum(Col2) group by Col1 pivot Col3 label Col1'Week ending'", 0)), "^.+♦", ), "where Col1 is not null", 0))
Need to combine 3 formulas into 1
Formula 1: List all items from Estimate tab =QUERY(Estimate!A2:D50,"SELECT * where C is not null",0) Formula 2: Locate task group matches within taskItemAssociations =ARRAYFORMULA(IFERROR(VLOOKUP(A9:A&B9:B&C9:C&D9:D, TRIM(IFERROR(SPLIT(TRIM(TRANSPOSE(QUERY(TRANSPOSE( {INDEX(QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN('task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D&"♦"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")), "select Col1,count(Col1) where Col1 is not null group by Col1 pivot Col2", 0),,1), IF( ISNUMBER(QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN('task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D&"♦"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")), "select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0)), QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN('task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D&"♦♥"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")), "select count(Col1) where Col1 is not null group by Col1 pivot Col2 limit 0", 0), )}) ,,999^99))), "♥"))), {2}, 0))) Formula 3: List all matches from taskData tab This result is really all I need. I'm just not sure how else to arrive here without all of the above. =QUERY(taskData!C2:O,"SELECT * where C = '"&E9&"'",0) Ideally, this would be a single ARRAYFORMULA in Tasks!A2 (currently occupied by notes) Here is my sheet
paste in A2 cell: =FILTER(taskData!C2:O, REGEXMATCH(taskData!C2:C, TEXTJOIN("|", 1, ARRAYFORMULA(IFERROR(VLOOKUP( INDEX(QUERY(Estimate!A2:D50,"where C is not null",0),,1)& INDEX(QUERY(Estimate!A2:D50,"where C is not null",0),,2)& INDEX(QUERY(Estimate!A2:D50,"where C is not null",0),,3)& INDEX(QUERY(Estimate!A2:D50,"where C is not null",0),,4), TRIM(IFERROR(SPLIT(TRIM(TRANSPOSE(QUERY(TRANSPOSE( {INDEX(QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN( 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C& 'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C& 'task-itemAssociations'!D2:D&"♦"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")), "select Col1,count(Col1) where Col1 is not null group by Col1 pivot Col2", 0),,1), IF( ISNUMBER(QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN( 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C& 'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C& 'task-itemAssociations'!D2:D&"♦"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")), "select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0)), QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN( 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C& 'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C& 'task-itemAssociations'!D2:D&"♦♥"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")), "select count(Col1) where Col1 is not null group by Col1 pivot Col2 limit 0", 0), )}) ,,999^99))), "♥"))), {2}, 0))))))
PowerBi calculating date only if another column has a value DAX
Trying to utilize powerbi to help me calculate a date. Currently it is calculating properly if the column "spend_start_Result" has a value, but if this column has no value it is still calculating and giving me a date of 12/30/1899. Is there something wrong with my DAX code? Arch_review_Calc = IF ( Projects[spend_start_Result] = BLANK (), 0, IF ( Projects[Complexity] = "Low", Projects[spend_start_Result] - 45, IF ( Projects[Complexity] = "Medium", Projects[spend_start_Result] - 60, IF ( Projects[Complexity] = "High", Projects[spend_start_Result] - 90, 0 ) ) ) ) I would like the Arch_review_calc column to be blank in that row if the spend_start_result column is blank in that row. Instead it is still calculating and I am unsure where I'm going wrong.
Your code replaces blanks with zeros, which are formatted as dates. To avoid that, instead of zeros use BLANK() function. I would re-write your formula as follows: Arch_review_Calc = IF ( ISBLANK ( Projects[spend_start_Result] ), BLANK (), SWITCH ( TRUE, Projects[Complexity] = "Low", Projects[spend_start_Result] - 45, Projects[Complexity] = "Medium", Projects[spend_start_Result] - 60, Projects[Complexity] = "High", Projects[spend_start_Result] - 90, BLANK () ) ) I am not sure about the last blank (inside the SWITCH statement) - if you want 0 instead of blank, replace BLANK() with 0.