Search code examples
google-sheetsgoogle-sheets-formula

Converted Filter function into Query


I have created filter function to Filter some sort of data and it is working fine but later converted it to Query but i am stcuk on one thing that how to Filter the Date Column based on month values like (1,2,3,4,5,6,7,8,9,10,11,12). I have created a Data validation for all 12 months.

your help will be much appreciated.

Filter Function:

=IFERROR(FILTER('Sheet1'!B:K,'Sheet1'!D:D=M4,month('Sheet1'!E:E)=X4),"No Data Available")

Query Function:

=QUERY({'Sheet1'!B:K}, "SELECT * WHERE Col2 contains '"&J4&"' AND Col3 contains '"&M4&"' AND Col4 = month(date'"&text(X4,"M")&"') ORDER BY Col2 ASC",0)

Unable to make this Query line AND Col4 = month(date'"&text(X4,"M")&"')


Solution

  • Try:

    =QUERY({'Sheet1'!B:K}, "SELECT * WHERE Col2 contains '"&J4&"' AND Col3 contains '"&M4&"' AND month(Col4) ="&X4-1&" ORDER BY Col2 ASC",0)