+ Reply to Thread
Results 1 to 10 of 10

Count if multiple functions are true?

  1. #1
    Registered User
    Join Date
    09-10-2014
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    18

    Count if multiple functions are true?

    Hi all,

    I would appreciate any help from the Excel gurus here! I have an excel file from say, an airline, that lists passengers who went through the airport. Some of them have a frequent flyer card. Of those passengers who DO NOT have a frequent flyer card, I want to mark which of them have the same surname of those WITH a frequent flyer card who scanned on the same date, same flight and within 1 minute of those with the card (i.e. they would be family members). I only want to mark ONE family member. I need to do this with a formula and when I say mark just a "count" string in a separate column is fine.

    This will ultimately be added into another formula. I've tried literally everything I can think of but I cannot get it to work.

    I've attached a sample of the file. I've separated the surnames of those who have a card and those who don't have a card. Then I did an if statement where if the data in column J is not "C" (just a requirement), AND the count of the flight number in column E is greater than 1, then vlookup the names of those who don't have a card against the list of those who do. It's still not accurate enough. It needs to reflect the same date as the person with the card, and within 1 minute of that person scanning. At this stage my eyes are rolling in my head so I might not be thinking about it accurately!

    ANY help is greatly appreciated. I need to get a formula in a single line and not have to rely on additional columns (beyond A-K). This is just part of the file so not every name will be visible but the very last entry should be a 100% match.
    Attached Files Attached Files

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Count if multiple functions are true?

    Please show the expected result for every records and explain in the nearby cell how you arrived it. So that we can give you the exact solution


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    09-10-2014
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    18

    Re: Count if multiple functions are true?

    Quote Originally Posted by :) Sixthsense :) View Post
    Please show the expected result for every records and explain in the nearby cell how you arrived it. So that we can give you the exact solution
    Hi Sixthsense,

    Please see the attached with the information you requested. For clarity it I've pasted it here also:

    The cells in this column should say "Count" if the surname from column H for those WITHOUT a Card matches the surname for those WITH a Card, where the flight ID in column E is the same AND the date in column A is the same AND the Entry Time in column B is within 1 minute of the person WITH the card.

    This should all be in one formula without relying on any other columns after A-K.

    You can see the formula for how you know a person has a card or not in column L. The formula for getting the surname is in column M.

    If the above criteria is not true, the cell should say "No"
    Help is greatly appreciated!
    Attached Files Attached Files

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Count if multiple functions are true?

    Try this in P2:

    =IF(COUNTIFS(H:H,N2&"*",E:E,E2,B:B,">="&B2-TIME(0,1,0),B:B,"<="&B2+TIME(0,1,0)),"Count","No")
    Remember what the dormouse said
    Feed your head

  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,064

    Re: Count if multiple functions are true?

    A really nice way of getting there from Rory. I had a much more cumbersome idea in mind. However, it needs one tweak (in my opinion) to meet the OP's requirement.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This removes the need to use column N.
    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

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Count if multiple functions are true?

    Ah yes, I missed the restriction on columns. I'd change it to:

    =IF(C2="TEST Airways",IF(AND(LEFT(RIGHT(G2,24),2)="BA",LEFT(RIGHT(G2,13),1)<>"M"),"No",IF(COUNTIFS(H:H,LEFT(H2,FIND("/",H2)-1)&"*",E:E,E2,B:B,">="&B2-TIME(0,1,0),B:B,"<="&B2+TIME(0,1,0)),"Count","No")),"No")

  7. #7
    Registered User
    Join Date
    09-10-2014
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    18

    Re: Count if multiple functions are true?

    Many thanks guys! I modified rompers original formula into this:

    =IF(COUNTIFS(H:H,IF(OR(AND(MID(G2,LEN(G2)-23,2)="BA",MID(G2,LEN(G2)-12,1)<>"M")),,LEFT(H2,FIND("/",H2)-1)&"*"),E:E,E2,B:B,">="&B2-TIME(0,1,0),B:B,"<="&B2+TIME(0,1,0)),"Count","No")

    So as not to use any new columns Thanks Romper

    It seems to work - but when I test it by changing the times to +1 or 2 minutes or - 1 or two minutes in the "Entry Time" column, I'm not always getting the correct result - could you please test and see if it's just me?
    Last edited by eoindub; 09-10-2014 at 10:11 AM.

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Count if multiple functions are true?

    Can you give a specific example?

  9. #9
    Registered User
    Join Date
    09-10-2014
    Location
    Dublin
    MS-Off Ver
    2010
    Posts
    18

    Re: Count if multiple functions are true?

    Quote Originally Posted by romperstomper View Post
    Can you give a specific example?
    For example in row 47 if I manually changed the time to say 06:55:27, "Count" still remains. Might be an excel specific thing though as when I copy a time value from another row, it changes?

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Count if multiple functions are true?

    I think the formula is wrong without the helper columns. Try this one, array entered with Ctrl+Shift+Enter, then filled down:

    =IF(AND(LEFT(RIGHT(G2,24),2)="BA",LEFT(RIGHT(G2,13),1)<>"M"),"No",IF(SUMPRODUCT((LEFT($H$2:$H$47,FIND("/",H2)-1)=IF(LEFT(RIGHT($G$2:$G$47,24),2)="BA",IF(LEFT(RIGHT($G$2:$G$47,13),1)<>"M",LEFT(H2,FIND("/",H2)-1),"Z"),"Z"))*($E$2:$E$47=E2)*($B$2:$B$47>=(B2-TIME(0,1,0)))*($B$2:$B$47<=(B2+TIME(0,1,0))))>0,"Count","No"))

+ 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. Multiple IF(FIND Functions with Multiple "TRUE"
    By maemaemae in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-13-2013, 04:44 PM
  2. [SOLVED] Using a function to count the number of rows in which multiple values are true
    By jimbowl in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-17-2013, 06:19 PM
  3. [SOLVED] Count occurences of a given value in Col A with multiple conditions being true
    By Howard Gale in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-17-2013, 11:26 AM
  4. Replies: 4
    Last Post: 01-08-2013, 09:04 AM
  5. Excel 2007 : Multiple Conditional Count Functions
    By J Morrow in forum Excel General
    Replies: 2
    Last Post: 05-17-2011, 03:00 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