Help needed with QUERY function in Google Sheets

Hey everyone,

I’m struggling with a QUERY formula in my Google Sheets project. I’m trying to set it up so that when a checkbox is selected, it pulls data from two different sheets. I’ve been experimenting with various approaches, but nothing seems to work correctly.

Here’s what I’ve attempted so far:

=QUERY({Sheet1!A:D; Sheet2!A:D}, 
 "SELECT * WHERE Col1 = 'true'", 0)

This formula is just an example and doesn’t work as intended. I’m not sure if I’m structuring it correctly or if there’s a better way to achieve what I want.

Can anyone offer some guidance on how to properly set up this QUERY to fetch data from multiple sheets based on a checkbox selection? Any tips or explanations would be greatly appreciated. Thanks in advance for your help!

hey emma, i’ve dealt with similar stuff before. try this:

=QUERY({Sheet1!A:D; Sheet2!A:D}, “select * where Col1 = TRUE”, 0)

make sure ur checkbox is in the first column. if it’s not, change Col1 to whatever column it’s in. hope this helps! lemme know if u need more help

I’ve found that using QUERY with multiple sheets can be tricky. Here’s a method that’s worked well for me:

=ARRAYFORMULA(QUERY({Sheet1!A:D; Sheet2!A:D}, “SELECT * WHERE Col1 = TRUE”, 0))

This combines the data from both sheets into a single array, then applies the QUERY. Make sure your checkbox column is the first one in each sheet for this to work correctly.

One thing to watch out for: if your sheets have different column structures, you might need to adjust the ranges to match. Also, using ARRAYFORMULA can help with performance, especially for larger datasets.

If you’re still having issues, it might be worth checking if your checkboxes are actually returning TRUE/FALSE values. Sometimes they can return 1/0 instead, which would require a slight modification to the formula.

I’ve encountered similar challenges with QUERY functions across multiple sheets. One approach that’s worked well for me is using an array formula combined with FILTER. Here’s a structure you might find helpful:

=QUERY({FILTER(Sheet1!A:D, Sheet1!E:E=TRUE); FILTER(Sheet2!A:D, Sheet2!E:E=TRUE)}, “SELECT *”, 0)

This assumes your checkbox is in column E on both sheets. The FILTER function first selects only the rows where the checkbox is TRUE, then the QUERY combines and processes the results.

Remember to adjust the column references based on your actual data layout. Also, ensure your column headers match across sheets to avoid confusion in the results.

If you’re dealing with large datasets, you might want to consider using IMPORTRANGE for better performance, especially if the sheets are in different workbooks. It’s a bit more complex to set up, but it can significantly improve speed for bigger projects.