+ Reply to Thread
Results 1 to 10 of 10

Want formula to return specific value and discard else than specifc.

  1. #1
    Registered User
    Join Date
    07-21-2018
    Location
    Egypt
    MS-Off Ver
    365
    Posts
    4

    Want formula to return specific value and discard else than specifc.

    Hello,

    i have big excel file with more 500K entries .. im looking for help to do the following,Example as below:
    ColumnX:
    22
    22
    22
    33
    33
    44
    11
    ColumnY: (Infront of each value in ColumnX)
    Red
    Blue
    Black
    Red
    Blue
    Blue
    Black

    Now what i want to have to return for me only the value in ColumnX which only have Vlaue with"Red" & "Blue" and if the value have more than "Red" or "Blue" Dont get it for me.

    So what what im expecting to see as results back for me is Only "33" is my wanted value and rest are not in the criteria cause either its having more than i want or less.

    Thanks.

  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
    43,984

    Re: Want formula to return specific value and discard else than specifc.

    With a helper column, in Z2, copied down:

    =COUNTIF(X:X,X2)

    in AB2, an array formula, copied down:
    =IFERROR(INDEX(X:X,SMALL(IF(($Y$2:$Y$8={"Red","Blue"})*($Z$2:$Z$8=2)*(COUNTIF($AB$1:AB1, $X$2:$X$8)=0),ROW($Y$2:$Y$8)),ROWS($1:1))),"")

    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.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    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
    43,984

    Re: Want formula to return specific value and discard else than specifc.

    ...or since you have the latest version of Excel, an ordinary formula:

    =IFERROR(INDEX(X:X,AGGREGATE(15,6,ROW($Y$2:$Y$8)/(($Y$2:$Y$8={"Red","Blue"})*($Z$2:$Z$8=2)*(COUNTIF($AB$1:AB1, $X$2:$X$8)=0)),ROWS($1:1))),"")

    ... still needing the helper.

  4. #4
    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
    43,984

    Re: Want formula to return specific value and discard else than specifc.

    Ignore the two previous replies... they're wrong.

  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
    43,984

    Re: Want formula to return specific value and discard else than specifc.

    helper in Z2:
    =AND(COUNTIFS($X:$X,X2)=2,SUM(COUNTIFS(X:X,X2,Y:Y,{"red","blue"}))=2)

    non-array formula in AB2:
    =IFERROR(INDEX(X:X,AGGREGATE(15,6,ROW($X$2:$X$8)/(($Z$2:$Z$8=TRUE)*(COUNTIF($AB$1:AB1, $X$2:$X$8)=0)),ROWS($1:1))),"")
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 07-21-2018 at 04:25 AM.

  6. #6
    Registered User
    Join Date
    07-21-2018
    Location
    Egypt
    MS-Off Ver
    365
    Posts
    4

    Re: Want formula to return specific value and discard else than specifc.

    Thanks a lot Glenn looks its typically fitting my needs i will do a test right now on my bigger sheet but the logic seems ok

  7. #7
    Registered User
    Join Date
    07-21-2018
    Location
    Egypt
    MS-Off Ver
    365
    Posts
    4

    Re: Want formula to return specific value and discard else than specifc.

    Hello Glenn, i have applied the formula and it works fine. but looked into the file looks i will need to do another modification.. let me explain here:

    ColumnA: (Account #)
    1111
    1111
    1111
    2233
    2233
    3333
    3333
    ColumnB: (Active Service)
    Full
    Partial
    Premium
    Gold
    Silver
    Labor

    What im expecting as results as below:
    If Account# 1111 have Any of the following "Gold,Premium,Silver" Then its fall into the criteria i want, But if its having "Gold,Premium,Silver,Labor or any of others than Gold/Premium/Silver" then its out of my criteria.

    hope i could explain well.

    thanks.

  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
    43,984

    Re: Want formula to return specific value and discard else than specifc.

    No. Post a sample sheet that shows clearly what is to be counted and what is not. I do not uuserstand this bit at all:

    But if its having "Gold,Premium,Silver,Labor or any of others than Gold/Premium/Silver" then its out of my criteria.

    However, explain the complete criteria. Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

  9. #9
    Registered User
    Join Date
    07-21-2018
    Location
    Egypt
    MS-Off Ver
    365
    Posts
    4

    Re: Want formula to return specific value and discard else than specifc.

    Hello Glenn, i have attached here the excel file with the Sheet names "Sample" hope that would explain what i want to modify in the formula.

    Thanks.
    Attached Files Attached Files

  10. #10
    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
    43,984

    Re: Want formula to return specific value and discard else than specifc.

    A simpler one. Helper:
    =SUM(COUNTIFS(A:A,A2,B:B,{"Full","Partial","Pemium","Labor"}))

    Main formula:
    =IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$8)/(($C$2:$C$8=0)*(COUNTIF($E$1:E1, $A$2:$A$8)=0)),ROWS(E$2:E2))),"")

    see sheet.
    Attached Files Attached Files

+ 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. Print specific page on specifc sheet
    By Bugge in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-09-2018, 05:30 PM
  2. Index Formula using max and excluding specifc value
    By bswitalski in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-17-2013, 09:26 AM
  3. Replies: 3
    Last Post: 12-18-2012, 07:19 PM
  4. Replies: 3
    Last Post: 06-20-2012, 07:16 AM
  5. formula to autopopulate a cell with specifc data from another
    By boltoncalling in forum Excel General
    Replies: 5
    Last Post: 01-11-2012, 12:55 PM
  6. Macro to discard rows with a specific non-colored cell
    By patounet in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-27-2011, 12:46 AM
  7. Importing specific data from a .txt file to specifc cells in a worksheet?
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 01-11-2011, 11:01 AM

Tags for this Thread

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