Search code examples
sortinggoogle-sheetsimportgoogle-sheets-formulagoogle-query-language

Sort by date with IMPORTRANGE in Sheets


I am helping my son with a making a master spreadsheet using IMPORTRANGE formula in sheets. This is for keeping track of parts and orders. Then with multiple sheets being linked to the master, he needs to be able to sort all the data by the Due Date column. The master needs to be updated in real time from the individual sheets and the IMPORTRANGE does that. I also need the all the data now to be sorted by the due date. But with IMPORTRANGE it doesn't allow you to sort the data. This is easy to do in regular Excel when you do a "paste link". But in sheets it's a pain. As a work around, I'm having to copy and paste values of all of the master data into a separate sheet so I can set up filters to sort by the due date. But once that happens, that data is now static and is no longer being updated in real time. So copying and pasting the data needs to happen daily to be on top of the due dates. There has to be an easier way to do this. So here's the formula that's used in one of the sheets,

=IMPORTRANGE("https://docs.google.com/spreadsheets/d/1_DbCYLX1tc9cMezqzbz9W7FGCUgxbmmdEhjUNU9z6T0/edit#gid=1986402868","32102!A2:M29")

The due date is the header name in the 3rd column. What is needed in order to sort all of the master data from the sheets that have been added with IMPORTRANGE?


Solution

  • try:

    =QUERY({
     IMPORTRANGE("1_DbCYLX1tc9cMezqzbz9W7FGCUgxbmmdEhjUNU9z6T0", "32102!A1:M29"); 
     IMPORTRANGE("1_DbCYLX1tc9cMezqzbz9W7FGCUgxbmmdEhjUNU9z6T0", "32102!A2:M29")}, 
     "order by Col3 asc", 1)
    

    or desc instead of asc if you need so in descending order