Share via

Fileter between two numbers

Andy Stewart 0 Reputation points
2026-04-29T09:34:42.8333333+00:00

I have the following formula below. It all works well, however I would like some more control.

In (CHOOSECOLS(x,12)<12) I have it set to filter to <12. I would like it to be <3 and >12.

Would love some help. Thank you.

=LET(x,VSTACK(

IF(COUNTA('Sales Pipeline Data'!E3:E5079)>0,OFFSET('Sales Pipeline Data'!E3,0,0,COUNTA('Sales Pipeline Data'!E3:E5079),15),{"","","","","","","","","","","","","","",""})

),y,SORT(FILTER(CHOOSECOLS(IF(x="","",x),1,12),(CHOOSECOLS(x,1)<>"")(CHOOSECOLS(x,7)<>"")(CHOOSECOLS(x,9)="")*(CHOOSECOLS(x,12)<12)),2,-1),IF(IFERROR(ROWS(y),0)<>0,y,""))

Microsoft 365 and Office | Excel | For home | MacOS
0 comments No comments

1 answer

Sort by: Most helpful
  1. Marcin Policht 88,075 Reputation points MVP Volunteer Moderator
    2026-04-29T11:14:03.6133333+00:00

    Looks like your condition only checks one side: (CHOOSECOLS(x,12)<12). To make it “less than 3 OR greater than 12”, you should explicitly combine two logical tests with a plus + (which acts like OR in array formulas).

    Replace that part with:

    ((CHOOSECOLS(x,12)<3)+(CHOOSECOLS(x,12)>12))
    

    So your full formula becomes:

    =LET(x,VSTACK(
    IF(COUNTA('Sales Pipeline Data'!E3:E5079)>0,OFFSET('Sales Pipeline Data'!E3,0,0,COUNTA('Sales Pipeline Data'!E3:E5079),15),{"","","","","","","","","","","","","","",""})
    ),
    y,SORT(
    FILTER(
    CHOOSECOLS(IF(x="","",x),1,12),
    (CHOOSECOLS(x,1)<>"")*
    (CHOOSECOLS(x,7)<>"")*
    (CHOOSECOLS(x,9)="")*
    ((CHOOSECOLS(x,12)<3)+(CHOOSECOLS(x,12)>12))
    ),
    2,-1
    ),
    IF(IFERROR(ROWS(y),0)<>0,y,"")
    )
    

    The key idea is that * acts like AND, while + acts like OR in these array conditions.


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.