Home > other >  google sheet script filter and query based on checkbox and date
google sheet script filter and query based on checkbox and date

Time:01-02

I have 2 sheets. 1 sheet with 3 columns: 1 column with dates, 1 column with data and one with checkboxes

The other sheet I want to apply the query on If a checkbox is checked that copy a row with specific column based on the date of 2 cells on the target sheet. (one cell contains month (januari, second cell contains year 2023)

https://docs.google.com/spreadsheets/d/18mhJ4SOZsDzh5Vp-FMWtvcb17ZbBesj_CGyCUa4hUxc/edit

The query part works:

=QUERY(Data!A1:D, "select B,A,C where D=TRUE")

But then howto integrate the date filter. I need some guidance, sometimes I cant get my head around it.

=QUERY(filter(Data!A1:D100, "select B,A,C,D where D=TRUE",TEXT(Data!A1:A100,"yyyMMMM") = $D$1 & $B$1))

Latest code I came up with, but does not work.

Suggestions are welcome

CodePudding user response:

Use filter() with two criteria, like this:

=filter( 
  { Data!B1:B, Data!A1:A, Data!C1:C }, 
  Data!D1:D, 
  text(Data!A1:A, "MMMyyyy") = left(B1, 3) & D1 
)

...where column Data!A1:A contains numeric date values, cell B1 contains a month name as a text string and D1 contains a year as a number.

  • Related