+ Reply to Thread
Results 1 to 18 of 18

COUNTIF non duplicate values that begin with TWO choices

  1. #1
    Registered User
    Join Date
    02-18-2014
    Location
    london, england
    MS-Off Ver
    Excel 2010
    Posts
    57

    COUNTIF non duplicate values that begin with TWO choices

    Hi guys,

    I have a very cool function that was created with a help here in this forum. Now I need to make on adjustment to it. I need to search fro two options.
    I need to search not just C410 in a listed reference column, but also C300. I know there is an OR function for it, just don't know where to put it in.

    The function is:

    =SUM(IF(FREQUENCY(IF(LEFT('C300-C410'!C16:C2810,4)="C410",MATCH('C300-C410'!C16:C2810,'C300-C410'!C16:C2810,0)),ROW('C300-C410'!C16:C2810)-ROW('C300-C410'!C15)+1),1))

    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: COUNTIF non duplicate values that begin with TWO choices

    No spreadsheet attached, so untested:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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
    Registered User
    Join Date
    02-18-2014
    Location
    london, england
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: COUNTIF non duplicate values that begin with TWO choices

    Thanks Glenn,

    The function gives #VALUE error. Please find the spreadsheet attached.
    It is quite reduced, as the size didn't allow all of it to be attached here.

    Thanks!!

    Book1.xlsx

  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: COUNTIF non duplicate values that begin with TWO choices

    This is not as elegant as I had hoped, but it works...

    Dont forget it's an array formula and must be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-18-2014
    Location
    london, england
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: COUNTIF non duplicate values that begin with TWO choices

    Thank you Glenn, it does the job!

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

    Re: COUNTIF non duplicate values that begin with TWO choices

    You're welcome...

  7. #7
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,913

    Re: COUNTIF non duplicate values that begin with TWO choices

    =sum(if(frequency(if(left('c300-c410'!c16:c1071,4)={"c300","c410"},match('c300-c410'!c16:c1071,'c300-c410'!c16:c1071,0)),row('c300-c410'!c16:c1071)-row('c300-c410'!c15)+1),1))
    try this array formula
    (shift+ctrl+enter)
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  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: COUNTIF non duplicate values that begin with TWO choices

    Nflsales, an elegant solution!! I hadn't thought of that. Do you know why an OR function failed to work for me, when I tried it?

  9. #9
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,913

    Re: COUNTIF non duplicate values that begin with TWO choices

    I think OR / AND Functions will not deal with array, it will give single true or false
    for more details evalueate the formula, there you can find it.

  10. #10
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: COUNTIF non duplicate values that begin with TWO choices

    Here is more refined solution.
    Please Login or Register  to view this content.
    I have used matrix multiplication to convert the n x 2 array in to n x 1.
    So here is the explanation with a small example
    --(LEFT('C300-C410'!C16:C1071,4)={"c300","c410"} portion will give a n X 2 array just as following:-

    T T
    F F
    T F
    F T multiplied by {1 , 1}
    T F
    T T
    . .
    . .
    . .
    n n

    to give ( just as simple matrix multiplication does.. n x 2 multiplied by 2 x 1 to give n x 1

    T * 1 + T * 1 = 2
    F * 1 + F * 1 = 0
    T * 1 + F * 1 = 1
    like this till n..
    this is how it will refine it and convert it into same sized array as MATCH('C300-C410'!C16:C1071,'C300-C410'!C16:C1071,0)) is of.
    So what I actually meant is, this way , we can add more exceptions or inclusions to {"c300","c410"} array
    by adding ",1" (without quotes ) in the mmult second argument {1,1} like for {"c300","c410", "c411"}, Mmult argument would be {1,1,1}.
    You can find some serious and FLEXIBLE implementations of matrics multiplications in the sheet 2 of attachment in Post #9 in the following link:-
    http://www.excelforum.com/excel-form...t-formula.html

    File can be directly downloaded from here:-
    http://www.excelforum.com/attachment...ller-mod1.xlsm
    Last edited by Vikas_Gautam; 12-30-2014 at 04:19 PM.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  11. #11
    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: COUNTIF non duplicate values that begin with TWO choices

    Vikas,

    I have yet to find a "layman's guide" to MMULT. Can you point me towards some good tutorials?

  12. #12
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: COUNTIF non duplicate values that begin with TWO choices

    Hi, Glenn,
    I have made edited the above post for some advanced implementation.
    Actually, I learnt some basics from XOR, an expert here, and rest is my own application.
    if you know simple matrix multiplication, you can easily think of applying it.
    However, you can refer excel inbuilt help and google.
    If you learn anything new then please share it.
    I am gonna make a full article on it and share it soon in tips and tutorial section with OR and AND conditions factored in it.
    Meanwhile, you can think of it as well.
    Good Luck.

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: COUNTIF non duplicate values that begin with TWO choices

    Quote Originally Posted by Glenn Kennedy View Post

    I have yet to find a "layman's guide" to MMULT. Can you point me towards some good tutorials?
    I tried to explain how it works in this post from several years ago...

    http://www.tech-archive.net/Archive/.../msg00758.html
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  14. #14
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: COUNTIF non duplicate values that begin with TWO choices

    Very nice post Volko sir,
    Exactly what I meant, may be I reinvented it.

  15. #15
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: COUNTIF non duplicate values that begin with TWO choices

    Hi tony sir,
    If you can tell with your nice speed checking codes,that:-
    Which one is faster Array multiplication or
    Matrics multiplication..?
    Because I have some nice ideas with Matrics multiplication...

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: COUNTIF non duplicate values that begin with TWO choices

    The code to test calculation times can be found here:

    http://msdn.microsoft.com/en-us/library/aa730921.aspx

    If you want me to test if for you, you'd have to give me a sample file with data and the formulas you want to test.

  17. #17
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: COUNTIF non duplicate values that begin with TWO choices

    Okay thanks,
    I will prepare the matter, try the code myself first and let you know if there is any problem.

  18. #18
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: COUNTIF non duplicate values that begin with TWO choices

    Since I do this kind of testing often I put the code in my Personal.xls file then added buttons to my toolbars that run the code.

+ 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. [SOLVED] COUNTIF non duplicate values that begin with
    By LinaVa in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-17-2014, 11:58 AM
  2. COUNTIF non duplicate values that begin with
    By LinaVa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2014, 09:23 AM
  3. COUNTIF one of three choices
    By sctlippert in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-10-2011, 02:57 PM
  4. COUNTIF - one of three choices
    By sctlippert in forum Excel General
    Replies: 1
    Last Post: 04-09-2011, 05:38 PM
  5. Duplicate Menu Choices
    By JCLSB in forum Excel General
    Replies: 1
    Last Post: 12-20-2005, 09:35 PM

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