• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel Filter Function (Microsoft 365)

Sarravana Kumar

New Member
Hello All,

I need help with the Filter Function. I have attached the sample data for reference with the current result & expected results.

Thank you in advance,
 

Attachments

  • New Filter Function.xlsx
    16.9 KB · Views: 13
This version doesn't create a formula so much, it more aims at creating a 'solution' at sheet level using Lambda.
1695818281043.png
Code:
Filterλ(table, drivers)
= LET(
    driverFields, TAKE(table, , -2),
    criteriaMatched, BYROW((driverFields = drivers) + ISBLANK(drivers), Andλ),
    FILTER(DataSource, criteriaMatched)
  )
 

Attachments

  • New Filter Function.xlsx
    25.8 KB · Views: 6
Hi Peter,

Thanks a ton, this works like magic.

I am trying to learn the Lambda function through youtube, in the interim could you pls. help me how the code will change if I have five variables instead of 2 in Drivers.

Earlier was only Job Name & Division, I need to add may be another 3 like Manager, Location, Management Level.

Thank you again.
 
Assuming the driverFields are still the rightmost fields of the Table you simple select a larger number in the definition which is the first line of the Lambda function, e.g.
Code:
Filterλ(table, drivers)
=LET(
    driverFields, TAKE(table, , -3),
    criteriaMatched, BYROW((driverFields = drivers) + ISBLANK(drivers), Andλ),
    FILTER(DataSource, criteriaMatched, "No matches")
)
More effort will go into the validation lists than the code! If the fields do not form a contiguous block to the right of the Table you would need a slight change of strategy and use CHOOSECOLS rather than TAKE to identify the driverFields.

1695843286823.png
 
Back
Top