{"id":22497,"date":"2019-12-17T11:55:24","date_gmt":"2019-12-17T10:55:24","guid":{"rendered":"https:\/\/blog.sheetgo.com\/?p=22497"},"modified":"2026-10-13T16:03:31","modified_gmt":"2026-10-13T14:03:31","slug":"combiner-une-requete-avec-un-import-dans-google-sheets","status":"publish","type":"post","link":"https:\/\/www.sheetgo.com\/fr\/blog\/google-sheets-formulas\/combine-query-with-importrange-in-google-sheets\/","title":{"rendered":"Combiner QUERY et IMPORTRANGE dans Google Sheets"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; admin_label=&#8221;section&#8221; _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221; da_is_popup=&#8221;off&#8221; da_exit_intent=&#8221;off&#8221; da_has_close=&#8221;on&#8221; da_alt_close=&#8221;off&#8221; da_dark_close=&#8221;off&#8221; da_not_modal=&#8221;on&#8221; da_is_singular=&#8221;off&#8221; da_with_loader=&#8221;off&#8221; da_has_shadow=&#8221;on&#8221; da_disable_devices=&#8221;off|off|off&#8221;][et_pb_row admin_label=&#8221;row&#8221; _builder_version=&#8221;4.16&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.16&#8243; custom_padding=&#8221;|||&#8221; global_colors_info=&#8221;{}&#8221; custom_padding__hover=&#8221;|||&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_text _builder_version=&#8221;4.27.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>Combining QUERY with IMPORTRANGE allows you to pull in data from different spreadsheets and perform advanced queries on it. Whether you&#8217;re managing project progress, financial data, or team efforts, mastering these functions can enhance your productivity and data management.<\/p>\n<p><a href=\"https:\/\/www.sheetgo.com\/blog\/google-sheets-formulas\/importrange\/\">IMPORTRANGE<\/a> is one of the most useful Google Sheets functions. As the name suggests, it imports a range of cells from one spreadsheet to another.<\/p>\n<p>On the other hand, <a href=\"https:\/\/www.sheetgo.com\/blog\/google-sheets-formulas\/query-formula-google-sheets\/\">QUERY<\/a> is an incredibly versatile formula, essentially allowing you to use your spreadsheet as a database. With SQL-like query language, you can look up, sum, count, average, filter and sort data.<\/p>\n<p>Below you&#8217;ll find the syntax, five examples, and a step-by-step setup in two real files, including how to allow access and how to group and sort the imported data.<\/p>\n<p>[\/et_pb_text][et_pb_video_slider _builder_version=&#8221;4.23.1&#8243; _module_preset=&#8221;default&#8221; custom_margin=&#8221;15px||15px||true|false&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][et_pb_video_slider_item src=&#8221;https:\/\/www.youtube.com\/watch?v=H4CvUq1vbjM&#8221; _builder_version=&#8221;4.23.1&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221; show_image_overlay=&#8221;off&#8221;][\/et_pb_video_slider_item][\/et_pb_video_slider][et_pb_text module_id=&#8221;how&#8221; _builder_version=&#8221;4.24.1&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3>How to use QUERY with IMPORTRANGE in Google Sheets<\/h3>\n<p>This combination applies QUERY directly to the data transferred with IMPORTRANGE to filter specific columns, rows, and ranges.<\/p>\n<p>It\u2019s a real time-saver when working with multiple spreadsheets, as you only pull in the exact data you need. It also allows you to format the data within your query instead of afterwards, which saves you an additional step.<\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;syntax&#8221; _builder_version=&#8221;4.24.1&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h4>Syntax<\/h4>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.16&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]=QUERY(IMPORTRANGE(spreadsheet_url, range_string), query, [headers])[\/et_pb_text][et_pb_text _builder_version=&#8221;4.24.1&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<ul>\n<li><b>spreadsheet_url<\/b> \u2013 the link to the spreadsheet where data is imported from.<\/li>\n<li><b>range_string<\/b> \u2013 range of cells to be imported. This can be further broken down into two components:\u00a0\n<ul>\n<li><b>sheet_name <\/b>\u2013 the name of the sheet with the desired data\u00a0<\/li>\n<li><b>cell_range<\/b> \u2013 the range of the cells within this sheet<\/li>\n<\/ul>\n<\/li>\n<li><b>query<\/b> \u2013 criteria of which data to transfer. Query handles language functions (Select, Group by, etc.) and data manipulation functions (Avg, Sum, Count, and Multiply).<\/li>\n<\/ul>\n<p>[\/et_pb_text][et_pb_code _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_code][et_pb_text module_id=&#8221;combination&#8221; _builder_version=&#8221;4.27.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3>How does this combination work?<\/h3>\n<p>Whenever you combine functions, things can get a bit confusing. To avoid that, let\u2019s look at what\u2019s going on in this syntax.<\/p>\n<p>First, let\u2019s focus on QUERY. This function can manipulate data in many ways, but always needs to start with a data source.<\/p>\n<p>In many cases this is data from another tab on the same spreadsheet. But as you know, this article deals with importing data from another spreadsheet. As a result, we will use the IMPORTRANGE function to feed data into QUERY.<\/p>\n<p>IMPORTRANGE is a simple function: just input the link to the spreadsheet and the range you want to import. The first time you connect two files, it shows a #REF! error until you allow access. The step-by-step setup further down shows where to click.<\/p>\n<p>This imported data can be plugged into the QUERY function. After all you need to input are the query parameters, which dictate how the data will be manipulated and displayed. The examples below illustrate this.<\/p>\n<p>Just remember, the structure of the syntax remains similar, no matter which function you nest inside Google Sheets\u2019 QUERY function.<\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;example1&#8243; _builder_version=&#8221;4.24.1&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h4>Example 1: Import and Query<\/h4>\n<p>In the following examples, I\u2019ll use this geographical data as the source data:<\/p>\n<p>[\/et_pb_text][et_pb_code _builder_version=&#8221;4.16&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_code][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2021\/03\/1.-Query-Importrange-data.png&#8221; alt=&#8221;QUERY IMPORTRANGE source data \u2014 country list with region and last data date in Google Sheets&#8221; title_text=&#8221;Country list with region and last data date in Google Sheets&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; width=&#8221;640px&#8221; max_width=&#8221;640px&#8221; height=&#8221;440px&#8221; max_height=&#8221;440px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.24.1&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>First, I import country data from 186 countries into a business spreadsheet. I\u2019ve merged items from a separate dataset based on certain criteria.<\/p>\n<p>Say I only want to import the data from countries in the Americas. To display only those specific cells, you simply need to apply the <b>Select <\/b>and <b>Where <\/b>clauses inside the QUERY function.<\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.16&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]=QUERY(IMPORTRANGE(&#8220;Spreadsheet_url&#8221;, &#8220;Population!B1:F187&#8221;),\u00a0&#8220;Select * Where Col1=&#8217;Americas&#8217; &#8220;)[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2021\/03\/2.-Query-Importrange-ex-1.png&#8221; alt=&#8221;QUERY IMPORTRANGE example \u2014 Select * Where Col1 equals Americas returns only countries in the Americas&#8221; title_text=&#8221;Select * Where Col1 equals Americas returns only countries in the Americas&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; width=&#8221;640px&#8221; max_width=&#8221;640px&#8221; height=&#8221;440px&#8221; max_height=&#8221;440px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.24.1&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>In this formula, QUERY searches data from a predefined range\/array according to specific criteria. Simultaneously, IMPORTRANGE imports the data into the target spreadsheet.<\/p>\n<p>Placing QUERY before IMPORTRANGE allows you to search (query) specific information from the data that is imported with IMPORTRANGE. This way, you only import the data you want to see in your spreadsheet.<\/p>\n<p>After IMPORTRANGE, you need to add search criteria. To import data from countries in the Americas, we used this query: <b>Select * Where Col1=\u2019Americas\u2019<\/b>.\u00a0 In plain English that translates to \u201cselect all the data that has \u201cAmericas\u201d in column 1\u201d.<\/p>\n<p>This formula comes in especially\u00a0 handy in situations where you want to merge data. If you work in online marketing for example, you might want traffic from various sources into one spreadsheet. It gives you a better overview of several data sources such as Google Analytics, Ahrefs, SEMrush or Google Search Console.<\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;example2&#8243; _builder_version=&#8221;4.24.1&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h4>Example 2: Import data within a date range<\/h4>\n<p>In this next example, I added search criteria after IMPORTRANGE. In this case, <b>where Col3 &gt; date \u20182019-07-01\u2019 and Col3 &lt; date \u20182019-12-30\u2019<\/b> imports the same data but only for items in the list that were published between those dates.<\/p>\n<p>Note that when you input a date into your query, you need to type the word date before it. Also don\u2019t forget to put the date in quotation marks. That\u2019s how the function knows you\u2019re referring to a date.<\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.16&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]=QUERY(IMPORTRANGE(&#8220;Spreadsheet_url&#8221;, &#8220;Population!A1:F187&#8221;), &#8220;where Col3 &gt; date &#8216;2019-07-01&#8217; and Col3 &lt; date &#8216;2019-12-30&#8242;&#8221;, 0)[\/et_pb_text][et_pb_text _builder_version=&#8221;4.24.1&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>You might apply this formula in logistics or even for a small business cash register. You can add up rows, columns and data ranges with changes in the data over time. If you\u2019re interested in changes to product lines, sales, and other KPIs over the course of the year, this formula can carry out monthly or quarterly comparative analysis.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2021\/03\/3.-Query-Importrange-date-range-v2.png&#8221; alt=&#8221;QUERY IMPORTRANGE date range \u2014 Col3 between two dates in 2019 filters the imported rows&#8221; title_text=&#8221;Col3 between two dates in 2019 filters the imported rows&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text module_id=&#8221;example3&#8243; _builder_version=&#8221;4.24.1&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h4>Example 3: Import and combine multiple spreadsheets with specific criteria<\/h4>\n<p>If you want to extract certain cells or a range from several spreadsheets, use the following formula. Here\u2019s how to merge data from multiple spreadsheets into one:<\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.16&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]=QUERY({IMPORTRANGE(&#8220;Spreadsheet_url&#8221;,&#8221;Sheet1!A1:P&#8221;);IMPORTRANGE(&#8220;Spreadsheet_url&#8221;,&#8221;Sheet1!A2:P&#8221;);IMPORTRANGE(&#8220;Spreadsheet_url&#8221;,&#8221;Sheet1!A2:P&#8221;)},&#8221;Select * where Col1&lt;&gt;&#8221;&#8221;,1)[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2021\/03\/4.-Query-Importrange-multiple-sheets.png&#8221; alt=&#8221;QUERY with multiple IMPORTRANGE \u2014 three spreadsheets stacked in curly brackets into one table&#8221; title_text=&#8221;Three spreadsheets stacked in curly brackets into one table&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.24.1&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>You need to use IMPORTRANGE for every spreadsheet you want to merge. Within the first IMPORTRANGE formula, I added the headers in A1:P.<\/p>\n<p>The other spreadsheets also contain the headers. However, they should not be imported multiple times. To avoid importing the header three times, I\u2019ve changed the range to A2:P on the second and third sheets.<\/p>\n<p>Lastly, the Where clause (where Col1&lt;&gt;\u2019\u2019) simply states that all cells that are not blank should be imported.<\/p>\n<p>Here are a few tips for importing multiple sheets:<\/p>\n<ul>\n<li>The list of imports needs to be enclosed in curly brackets and a semicolon must separate each IMPORTRANGE.<\/li>\n<li>The imported sheets must all have the same layout. For example, if the first column of all the sheets wasn\u2019t Country Name, the data wouldn\u2019t combine properly.<\/li>\n<li>Don\u2019t import the headers on every sheet \u2013 you only need one.<\/li>\n<li>Remember to allow access to all the spreadsheets you want to import from.<\/li>\n<\/ul>\n<p>This formula is really useful for business surveys (when you collect several spreadsheets with the same format). Likewise for educational purposes. When you hand out similar exercises to students or when you collect grades from various professors.<\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;example4&#8243; _builder_version=&#8221;4.24.1&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h4><b>Example 4: Import and Query Average Values<\/b><\/h4>\n<p>With this formula, I import the average population of each continent. As you can see, I add \u201cavg\u201d after the \u2018Select\u2019 clause and I put the column in parentheses. Next, add the query (the data you are looking for) after the Where clause. In this case, the query is \u2018Europe\u2019.<\/p>\n<p>Notice how on the rest of this spreadsheet I use multiple QUERY\/IMPORTRANGE functions to get average populations and total GDPs for different regions. Since QUERY is highly customizable, you can get all sorts of different outputs depending on your objective!<\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.16&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]=QUERY(IMPORTRANGE(&#8220;Spreadsheet_url&#8221;, &#8220;Population!A2:P187&#8221;), &#8220;Select avg(Col4) where Col2 contains &#8216;Europe&#8217; &#8220;)[\/et_pb_text][et_pb_text _builder_version=&#8221;4.24.1&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>QUERY function allows you to extract all arithmetic functions. This is a very helpful tool for traders and financial analysts. With it, you can look up values from a variety of investment spreadsheets and carry out calculations such as Present Value =PV, Future Value =FV and interest rate functions such as =IRR and =RATE.<\/p>\n<p>In addition: it\u2019s a more intuitive, natural language version of the complex <a href=\"https:\/\/www.sheetgo.com\/blog\/excel-functions\/index-match-excel\/\">INDEX-MATCH<\/a> formulas in Excel.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2021\/03\/5.-Query-Importrange-query-and-avg.png&#8221; alt=&#8221;QUERY IMPORTRANGE average \u2014 avg(Col4) returns the average population for Europe&#8221; title_text=&#8221;Avg(Col4) returns the average population for Europe&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text module_id=&#8221;example5&#8243; _builder_version=&#8221;4.24.1&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h4>Example 5: Import and Query Sum values<\/h4>\n<p>In this final example, the formula filters by continent, sums up each country\u2019s GDP and imports data from a separate spreadsheet.<\/p>\n<p>This is specifically helpful to create dashboards and reports of all kinds.<\/p>\n<p>[\/et_pb_text][et_pb_text module_class=&#8221;spreadsheet-function&#8221; _builder_version=&#8221;4.16&#8243; border_width_left=&#8221;4px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]=QUERY(IMPORTRANGE(&#8220;Spreadsheet_url&#8221;), &#8220;Select sum(Col5) where Col2 contains &#8216;Europe&#8217; &#8220;)[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2021\/03\/6.-Query-Importrange-query-and-sum.png&#8221; alt=&#8221;QUERY IMPORTRANGE sum \u2014 sum(Col5) returns the GDP total for Europe&#8221; title_text=&#8221;Sum(Col5) returns the GDP total for Europe&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; width=&#8221;640px&#8221; max_width=&#8221;640px&#8221; height=&#8221;440px&#8221; max_height=&#8221;440px&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text module_id=&#8221;how-to-set-up-query-with-importrange-bet&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2>How to set up QUERY with IMPORTRANGE between two files<\/h2>\n<p>The examples above use a placeholder for the spreadsheet URL. Here is the whole setup in a real pair of files, with the URL and the range in their own cells so the formula stays short.<\/p>\n<p>The example below is based on two files. The source file contains data on sales for all agents and products. The destination file is where I want to import and analyze data based on specific conditions.<\/p>\n<h3>Copy the source URL and cell range<\/h3>\n<p><strong>1.<\/strong> Open both the source and destination files in Sheets.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-source-and-destination-files.webp&#8221; alt=&#8221;QUERY IMPORTRANGE in Google Sheets \u2014 SALES_DATA source file with sales_id, sales_amount, sales_agent, product, and sales_team columns&#8221; title_text=&#8221;SALES_DATA source file with sales_id, sales_amount, sales_agent, product, and sales_team columns&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><strong>2.<\/strong> From the source file, copy the URL.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-copy-source-file-url.webp&#8221; alt=&#8221;IMPORTRANGE source URL \u2014 the SALES_DATA URL being copied from the browser address bar&#8221; title_text=&#8221;The SALES_DATA URL being copied from the browser address bar&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><strong>3.<\/strong> Paste the URL into the destination file.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-paste-source-url-to-destination.webp&#8221; alt=&#8221;IMPORTRANGE source URL \u2014 SALES_ANALYSIS file with the source URL pasted in B1&#8243; title_text=&#8221;SALES_ANALYSIS file with the source URL pasted in B1&#8243; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><strong>4.<\/strong> Go back to the source file and select the cell range. You can copy the cell range reference from the top-left corner, as shown below.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-select-and-copy-source-cell-range.webp&#8221; alt=&#8221;IMPORTRANGE cell range \u2014 range A1:E505 copied from the name box of the source file&#8221; title_text=&#8221;Range A1:E505 copied from the name box of the source file&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><strong>5.<\/strong> Paste the cell range reference into the destination file. I don\u2019t need to specify the sheet because it is on \u201cSheet1\u201d.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-paste-cell-range-reference.webp&#8221; alt=&#8221;IMPORTRANGE cell range \u2014 A1:E505 pasted in B2 of the destination file&#8221; title_text=&#8221;A1:E505 pasted in B2 of the destination file&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3>Add the QUERY function<\/h3>\n<p>I\u2019ll use a simple query with \u2018select\u2019 and \u2018where\u2019 clauses to import the rows where the \u201csales_team\u201d is the \u2018Southteam\u2019.<\/p>\n<p><strong>1.<\/strong> Start typing the formula for QUERY.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-add-query-function.webp&#8221; alt=&#8221;QUERY IMPORTRANGE formula \u2014 =QUERY( typed in A4 with the data, query, and headers hint&#8221; title_text=&#8221;=QUERY( typed in A4 with the data, query, and headers hint&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><strong>2.<\/strong> For the &#8216;data&#8217; argument, add IMPORTRANGE and reference the cells that hold its arguments, B1 and B2.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-add-importrange-function.webp&#8221; alt=&#8221;QUERY IMPORTRANGE formula \u2014 IMPORTRANGE(B1,B2) added as the data argument of QUERY&#8221; title_text=&#8221;IMPORTRANGE(B1,B2) added as the data argument of QUERY&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><strong>3.<\/strong> For the \u2018query\u2019 argument, I will use &#8220;Select * Where Col5=&#8217;Southteam'&#8221;. \u2018Col5\u2019 is the column \u201csales_team\u201d, which should match the \u201cSouthteam\u201d.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-add-query.webp&#8221; alt=&#8221;QUERY IMPORTRANGE formula \u2014 Select * Where Col5 equals Southteam added as the query argument&#8221; title_text=&#8221;Select * Where Col5 equals Southteam added as the query argument&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><strong>4.<\/strong> Press \u201cEnter\u201d to see the results.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-query-results.webp&#8221; alt=&#8221;QUERY IMPORTRANGE results \u2014 imported rows where sales_team is Southteam&#8221; title_text=&#8221;Imported rows where sales_team is Southteam&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><strong>5.<\/strong> You can easily add another condition by using the \u2018OR\u2019 operator. For instance, I can import the results for two different teams by adjusting the query as shown below.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-modify-query-with-or.webp&#8221; alt=&#8221;QUERY IMPORTRANGE with OR \u2014 query extended to Southteam OR Westteam in Col5&#8243; title_text=&#8221;Query extended to Southteam OR Westteam in Col5&#8243; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p><strong>6.<\/strong> As you can see in the screenshot below, the results now also contain the data for \u2018Westteam\u2019.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-modified-query-results.webp&#8221; alt=&#8221;QUERY IMPORTRANGE results \u2014 sales_team filter shows Southteam and Westteam rows&#8221; title_text=&#8221;Sales_team filter shows Southteam and Westteam rows&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3>Allow access between the files<\/h3>\n<p>If you\u2019re working with files that have never been connected before, you\u2019ll see an error message instead of the value when you press \u2018Enter\u2019. To see the actual value, you will have to approve access between sheets. Click the cell with the #REF! error, then click Allow access. You only need to do this once for each pair of files.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-approve-access-between-sheets.webp&#8221; alt=&#8221;IMPORTRANGE allow access \u2014 #REF! error with the You need to connect these sheets prompt and Allow access button&#8221; title_text=&#8221;#REF! error with the You need to connect these sheets prompt and Allow access button&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text module_id=&#8221;how-to-group-and-sort-imported-data-with&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2>How to group and sort imported data with QUERY<\/h2>\n<p>For the sake of simplicity, I\u2019ll use the data from the previous section. For my analysis, I want to see sales totals by team, as well as sales totals by sales agent.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-replace-query.webp&#8221; alt=&#8221;QUERY IMPORTRANGE example \u2014 a new formula started in A4 with IMPORTRANGE(B1,B2)&#8221; title_text=&#8221;A new formula started in A4 with IMPORTRANGE(B1,B2)&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3>Group by sales team<\/h3>\n<p>To group the results, I need to select the \u2018sales_team\u2019 column (5) and the sum of the \u2018sales_amount\u2019 column, then group by \u2018sales_team\u2019.<\/p>\n<p>The query looks like this: &#8220;Select Col5,sum(Col2) Group by Col5&#8221;.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-group-by-query.webp&#8221; alt=&#8221;QUERY IMPORTRANGE group by \u2014 Select Col5, sum(Col2) Group by Col5 typed in A4&#8243; title_text=&#8221;Select Col5, sum(Col2) Group by Col5 typed in A4&#8243; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>Press \u2018Enter\u2019 to see the results.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-group-by-results.webp&#8221; alt=&#8221;QUERY IMPORTRANGE group by \u2014 sales totals for Eastteam, Northteam, Southteam, and Westteam&#8221; title_text=&#8221;Sales totals for Eastteam, Northteam, Southteam, and Westteam&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3>Group by sales agent<\/h3>\n<p>As the name of the sales agent is in column 3, I need to modify the query and replace references to \u2018Col5\u2019 with \u2018Col3\u2019.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-new-group-by-query.webp&#8221; alt=&#8221;QUERY IMPORTRANGE group by \u2014 Group by Col3 formula in D4 to total sales per agent&#8221; title_text=&#8221;Group by Col3 formula in D4 to total sales per agent&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>Press \u2018Enter\u2019 to see the results.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-new-group-by-results.webp&#8221; alt=&#8221;QUERY IMPORTRANGE group by \u2014 sum of sales_amount per sales agent, sorted by name&#8221; title_text=&#8221;Sum of sales_amount per sales agent, sorted by name&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h3>Order by sales amount<\/h3>\n<p>As you can see in the previous screenshot, the function automatically sorts the column alphabetically by the name of the sales agent. However, I want to see the results by sales amount, in descending order.<\/p>\n<p>I can modify the previous query by adding &#8220;Order by sum(Col2) DESC&#8221; at the end.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-order-by-query.webp&#8221; alt=&#8221;QUERY IMPORTRANGE order by \u2014 Order by sum(Col2) DESC added to the group by query&#8221; title_text=&#8221;Order by sum(Col2) DESC added to the group by query&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<p>Press \u2018Enter\u2019 to see your results ordered by sales amount.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8221;https:\/\/static.sheetgo.com\/wp-content\/uploads\/2026\/10\/query-importrange-order-by-results.webp&#8221; alt=&#8221;QUERY IMPORTRANGE order by \u2014 sales agents ranked by total sales, highest first&#8221; title_text=&#8221;Sales agents ranked by total sales, highest first&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.22.2&#8243; _module_preset=&#8221;default&#8221; width=&#8221;100%&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;][\/et_pb_image][et_pb_text module_id=&#8221;sheetgo&#8221; _builder_version=&#8221;4.27.2&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2>Get the same results with Sheetgo connections<\/h2>\n<p>Sheetgo offers an intuitive and powerful alternative to the combination of QUERY and IMPORTRANGE in Google Sheets. With Sheetgo, you can import and process data automatically, so your spreadsheet data is ready for reports, dashboards, and AI.<\/p>\n<p>Coincidentally, one of the key data processing capabilities of Sheetgo offers QUERY filter. This feature enables you to perform advanced data queries similar to the QUERY function in Google Sheets. You can filter, sort, and manipulate data as it flows between your spreadsheets, all without the need for complex formulas.<\/p>\n<p>Why use Sheetgo over IMPORTRANGE? Here are just three reasons:<\/p>\n<ul>\n<li>Enhanced Data Management: Unlike IMPORTRANGE, Sheetgo provides a centralized dashboard where you can manage all your data connections.<\/li>\n<li>Scalability: Sheetgo can handle large datasets and multiple connections without the performance issues that IMPORTRANGE might encounter. This makes it ideal for businesses with complex data requirements.<\/li>\n<li>Advanced Filtering: With Sheetgo&#8217;s QUERY filter, you can perform sophisticated data manipulations directly within your workflows. This allows for more advanced data processing capabilities compared to IMPORTRANGE.<\/li>\n<\/ul>\n<p>Find out all the reasons <a href=\"https:\/\/www.sheetgo.com\/blog\/google-sheets-formulas\/importrange-vs-sheetgo\/\">why Sheetgo is the best IMPORTRANGE alternative<\/a>.<\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=&#8221;4.27.2&#8243; global_colors_info=&#8221;{}&#8221; theme_builder_area=&#8221;post_content&#8221;]<\/p>\n<h2>Conclusion<\/h2>\n<p>Now you\u2019ve got the lowdown on how to use QUERY with IMPORTRANGE, from allowing access between files to grouping and sorting the imported data. Now you can merge the power of these two functions, for another great combination check out <a href=\"https:\/\/www.sheetgo.com\/blog\/google-sheets-formulas\/vlookup-importrange\/\">How to use VLOOKUP and IMPORTRANGE<\/a>.<\/p>\n<p>If your dataset is too large for QUERY+IMPORTRANGE to handle, the <a href=\"https:\/\/www.sheetgo.com\/blog\/how-to-solve-with-sheetgo\/importrange-alternative\/\">no-formula IMPORTRANGE alternative<\/a> shows how to filter and connect Google Sheets at scale without crashing.<\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Combining QUERY with IMPORTRANGE allows you to pull in data from different spreadsheets and perform advanced queries on it. Whether you&#8217;re managing project progress, financial data, or team efforts, mastering these functions can enhance your productivity and data management. IMPORTRANGE is one of the most useful Google Sheets functions. As the name suggests, it imports [&hellip;]<\/p>\n","protected":false},"author":39,"featured_media":27673,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[54],"tags":[39,28],"class_list":["post-22497","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-sheets-formulas","tag-connections-t","tag-spreadsheets"],"acf":[],"permalink_manager":null,"_links":{"self":[{"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/posts\/22497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/comments?post=22497"}],"version-history":[{"count":0,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/posts\/22497\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/media\/27673"}],"wp:attachment":[{"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/media?parent=22497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/categories?post=22497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sheetgo.com\/fr\/wp-json\/wp\/v2\/tags?post=22497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}