+ Reply to Thread
Results 1 to 9 of 9

filter with multiple values

  1. #1
    Registered User
    Join Date
    12-04-2012
    Location
    india
    MS-Off Ver
    2021
    Posts
    45

    filter with multiple values

    Hi,

    I have an excel sheet with 2 columns.

    Column A has the name and column B has the branch.

    For one Name i want to check in column B if it has any of these 3 values which start with "mas" or "rel" or "dev" , if it does not then it should return a value zero in column C. if it has only one value out of the 3 then it should return 1 similarly for 2 and 3.

    for ex : in the attached sheet from Column A
    "Article" has all the 3 values it should show up 3
    "Cleanser" has only 2 values that start with either "mas" or "dev" or "rel" , it should show up 2
    "Claims" does not have any of the 3 values , it should show up as 0.

    with the pivot table i can group the values in Column A but cannot filter for 3 values in Column B.

    attached is the sample data.

    Appreciate the help.
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,141

    Re: filter with multiple values

    One way, with an array formula:

    =MIN(3,SUMPRODUCT(($A$2:$A$40=A2)*(IFERROR(SEARCH(TRANSPOSE($F$2:$F$4),$B$2:$B$40),0))))

    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Registered User
    Join Date
    12-04-2012
    Location
    india
    MS-Off Ver
    2021
    Posts
    45

    Re: filter with multiple values

    Quote Originally Posted by Glenn Kennedy View Post
    One way, with an array formula:

    =MIN(3,SUMPRODUCT(($A$2:$A$40=A2)*(IFERROR(SEARCH(TRANSPOSE($F$2:$F$4),$B$2:$B$40),0))))

    Don't type the curly brackets yourself - it won't work...
    Hi Glenn,

    Thank you for the formula, it seems to work for some cases and for some it is showing the incorrect count. for one particular name that i checked it is showing the count as 3 where as it should be 2 .

    I have modified the formula to change the row numbers to 7000 as it has data till that row.

    How ever it seems to work if i copy the data to another sheet with less rows, is the max number of rows an issue here?

    Attachment 645097

  4. #4
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: filter with multiple values

    Is 'master' is counted as 'mas' ?

    =SUM(COUNTIFS(A:A,A2,B:B,{"mas*","rel*","dev*"}))

    It's seem my formula is include 'master' in counting as well.

    Regards.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,141

    Re: filter with multiple values

    The problem my formula had was that it was counting mas in the middle of a term. This will count it ONLY at the start:

    =SUMPRODUCT(($A$2:$A$40=$A2)*(IFERROR((SEARCH(TRANSPOSE($F$2:$F$4),$B$2:$B$40)=1),0)))

    memem's is much simpler, but DO NOT use whole column ranges. It will be slow.

    in both cases, if you want the maximum value returned to be 3

    =MIN(3,formula_you_choose)
    Last edited by Glenn Kennedy; 10-13-2019 at 03:04 AM.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,141

    Re: filter with multiple values

    or is it more complicated than that??

    Do you want 1 or 2 for:

    XXX dev
    XXX blah
    XXX dev

    ie only 1 dev gets counted???

  7. #7
    Registered User
    Join Date
    12-04-2012
    Location
    india
    MS-Off Ver
    2021
    Posts
    45

    Re: filter with multiple values

    Apologies Glenn for the delay in reply and thank you for the other formula.
    Quote Originally Posted by Glenn Kennedy View Post
    or is it more complicated than that??

    Do you want 1 or 2 for:

    XXX dev
    XXX blah
    XXX dev

    ie only 1 dev gets counted???
    no this is not require because of the below reason.


    Quote Originally Posted by Glenn Kennedy View Post
    The problem my formula had was that it was counting mas in the middle of a term. This will count it ONLY at the start:

    =SUMPRODUCT(($A$2:$A$40=$A2)*(IFERROR((SEARCH(TRANSPOSE($F$2:$F$4),$B$2:$B$40)=1),0)))
    The above formula works fine but might need some tweaking. right now it will count if column b has either "dev" or "develop". I want the formula to count when it matches the exact string i.e "dev" if there is letter or a number or a underscore or anything after that it should ignore ex :dev25_ten or dev7685 or release_checking, master_test . It should not not count these values. Count it only when the value is either "mas" or "rel" or dev".

    Tried to use Exact function but was not able to get it to work.

    Thank you for the help!
    Last edited by zaveed; 10-29-2019 at 04:01 AM.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,141

    Re: filter with multiple values

    Use this, array entered:

    =SUMPRODUCT(($A$2:$A$40=$A2)*(IFERROR((SEARCH(TRANSPOSE($F$2:$F$4&" "),$B$2:$B$40&" ")=1),0)))

  9. #9
    Registered User
    Join Date
    12-04-2012
    Location
    india
    MS-Off Ver
    2021
    Posts
    45

    Re: filter with multiple values

    Quote Originally Posted by menem View Post
    Is 'master' is counted as 'mas' ?

    =SUM(COUNTIFS(A:A,A2,B:B,{"mas*","rel*","dev*"}))

    It's seem my formula is include 'master' in counting as well.

    Regards.
    Quote Originally Posted by Glenn Kennedy View Post
    Use this, array entered:

    =SUMPRODUCT(($A$2:$A$40=$A2)*(IFERROR((SEARCH(TRANSPOSE($F$2:$F$4&" "),$B$2:$B$40&" ")=1),0)))
    Thank you Glenn and menem!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Filter one column with multiple checkboxes on multiple values
    By J_Marley in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-14-2018, 02:39 PM
  2. Multiple Filter by Cell Values
    By EHansen in forum Office 365
    Replies: 3
    Last Post: 06-29-2015, 06:12 PM
  3. updating multiple pivot tables with multiple filter values
    By roush in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-11-2012, 08:56 PM
  4. Filter multiple criteria to only keep unique values
    By albardit18 in forum Excel General
    Replies: 2
    Last Post: 05-10-2012, 09:38 AM
  5. Filter out rows where multiple values are the same.
    By JohnnyDavidson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-18-2011, 09:07 PM
  6. filter for multiple column values
    By rgouette in forum Excel General
    Replies: 2
    Last Post: 03-10-2008, 02:08 PM
  7. Filter: Multiple values in a cell
    By pandora in forum Excel General
    Replies: 1
    Last Post: 12-06-2005, 03:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1