Mark
Mark

Reputation: 13

How to importrange based on date in filename?

There's a rolling list of live spreadsheets for each day with the filenames in this format, "ranking_file-2022-10-05".

I need my importrange query to always grab today's dated filename and another that always grabs the file from 7 days ago. Is this possible? Any help would be hugely appreciated.

Here's my current query which I need two versions of based on above:

=SORTN(SORT(QUERY(IMPORTRANGE("xxxxx/edit","ranking_file!A2:O250"),"Select Col1,Col4,Col7,Col5,Col14,Col15 where Col5 contains 'xxxxx' and Col15 contains 'Google.co.uk_' and Col4 is not null order by Col4 asc", ), 3, 1), 9^9, 2, 2, 1)

Upvotes: 0

Views: 94

Answers (1)

player0
player0

Reputation: 1

try:

=SORTN(SORT(QUERY(
 {IMPORTRANGE("xxxxx/edit","ranking_file-"&TEXT(TODAY(), e-mm-dd)&"!A2:O250")},
 "select Col1,Col4,Col7,Col5,Col14,Col15 
  where Col5  contains 'xxxxx' 
    and Col15 contains 'Google.co.uk_' 
    and Col4 is not null 
  order by Col4 asc", ), 3, 1), 9^9, 2, 2, 1)

Upvotes: 1

Related Questions