Search code examples
arrayssortinggoogle-sheetsgoogle-sheets-formulagoogle-query-language

Filter dates from different spreadsheets for the last 10 days in Google Sheets


I have a sheet with 4 tabs with several data, where the date and time of the registration of the reports is in the column A. I created a new tab which will gather all the other sheets data. So I am using QUERY:

=QUERY({
Sheet2!A1:D;
Sheet3!A1:D;
Sheet4!A1:D;
Sheet5!A1:D
},
"select * where Col2 is not null order by Col1",0)

However, I need to place in Sheet1 all the data sorted by the last 10 days:

https://docs.google.com/spreadsheets/d/1mzFEEZwDma0MAUUBnlmXvwWjCBpeDiaBDDXB584fu7A/edit#gid=0

Note: Query is already sorting by dates


Solution

  • try ascending:

    =SORT(QUERY(SORT({
     Sheet2!A1:D;
     Sheet3!A1:D;
     Sheet4!A1:D;
     Sheet5!A1:D}, 1, 0),
     "where Col2 is not null limit 10", 0))
    

    or descending:

    =QUERY(SORT({
     Sheet2!A1:D;
     Sheet3!A1:D;
     Sheet4!A1:D;
     Sheet5!A1:D}, 1, 0),
     "where Col2 is not null limit 10", 0)