+ Reply to Thread
Results 1 to 33 of 33

Countif(s): Need to properly count a flight plan

  1. #1
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Countif(s): Need to properly count a flight plan

    Hello all,
    This is not a normal flight plan spreadsheet. What I am doing is I have a flight plan: Plane going from "A" to "B" to "C" to "D" to "A", and a lot of other combinations of flights. I need to count the number of times that there are flights "A-B", "B-A", "C-D", and "D-C" while disregarding all other stops ("E", "F", "G", etc).
    I have used this: =COUNTIF(D9:R9,{"A","B"}) with a little success, but is is counting for the extra "A" as well as shown in the example flight plan above.

    Is there a way to create a criteria that specifically states that there has to be both in the row to count as one and leave off the excess "A"?

    Thanks folks, you guys to great work here.

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Countif(s): Need to properly count a flight plan

    how about this one?

    =COUNTIF(D9:R9,{ "A-B","B-A","C-D","D-C"})
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Forgive me, maybe I should have been a little more clear. I am trying to keep sensitive material out.
    I have dropdown lists with all the available bases to land (plus an "OTHER") The data input is easier this way for the other employees. The flight plan can also be something like: "A-E-B-D" and that would count as "1" because it did go from "A-B". Hope this helps.
    Last edited by 0311 Hesco; 08-26-2014 at 09:09 AM. Reason: grammar

  4. #4
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Or maybe if there was a way to only count if there were the same amount of "A" stops as "B" stops? Anyone?

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Countif(s): Need to properly count a flight plan

    Hi,

    Can you attach a workbook with an example or two together with your expected results?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  6. #6
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Air Movement Tracker.xlsx

    W4:Y12 is the area of concern. Also the numbers the formula should populate.
    W4:Y4 is what I need the formula for.
    The three combos I need are MSF-NRK, NRK-MSF; MSF-SBZ, SBZ-MSF; and NRK-SBZ, SBZ-NRK

    Hope this helps, This is the first time I've needed help on a spreadsheet. Thanks in advance!

  7. #7
    Forum Expert
    Join Date
    03-28-2014
    Location
    Hyderabad,India
    MS-Off Ver
    Excel 2013
    Posts
    1,887

    Re: Countif(s): Need to properly count a flight plan

    Hi try this
    =COUNTIFS(A:A,"A",B:B,"B")

    Punnam

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Countif(s): Need to properly count a flight plan

    Thanks, but sorry - still not sure I understand. Did you include your manually-calculated results in there, just so we know what we're aiming for?

    I can only see some COUNTIF formulas in those cells, though I presume those results are incorrect?

    Regards

  9. #9
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Yes the results from that countif formula are incorrect and the values in W4:Y12 are what I need to come out via the formula.

  10. #10
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Quote Originally Posted by Punnam View Post
    Hi try this
    =COUNTIFS(A:A,"A",B:B,"B")

    Punnam
    The problem with using this is that A:A might not always be "A".
    Sorry for the tricky problem.

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Countif(s): Need to properly count a flight plan

    So there can only ever be a maximum of 3 entries in a given row for the 2 desired flight codes?

    So if there are 2 (i.e. one of each - a "single" journey) then the result is 1; if there are 3 (i.e. one of one and two of the other - a "return" journey) then the result is 2?

    Or could it go back and forth multiple times in a single row?

    And your result for row 5 is not in error, i.e. it doesn't matter if there are other destinations in between (NRK to MSF to PSR to NRK)?

    Regards
    Last edited by XOR LX; 08-26-2014 at 10:52 AM.

  12. #12
    Forum Expert
    Join Date
    03-28-2014
    Location
    Hyderabad,India
    MS-Off Ver
    Excel 2013
    Posts
    1,887

    Re: Countif(s): Need to properly count a flight plan

    Hi,

    I have changed the layout . check it once.


    Punnam
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Quote Originally Posted by XOR LX View Post
    So there can only ever be a maximum of 3 entries in a given row for the 2 desired flight codes?

    So if there are 2 (i.e. one of each - a "single" journey) then the result is 1; if there are 3 (i.e. one of one and two of the other - a "return" journey) then the result is 2?

    Or could it go back and forth multiple times in a single row?

    And your result for row 5 is not in error, i.e. it doesn't matter if there are other destinations in between (NRK to MSF to PSR to NRK)?

    Regards
    Not exactly sure what you mean here. The dropdown list is a list of airports and they can fly in any manner to wherever. I need to track every time there is a flight either from MSF to NRK, NRK to MSF (in W:W); SBZ to MSF, MSF to SBZ (in X:X); and SBZ to NRK, NRK to SBZ (in Y:Y) these flights can have stops in between to places that I do not track. Maybe a better way to explain this is I am tracking the relationship between the three airports. Not in error. Thanks guys!

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Countif(s): Need to properly count a flight plan

    Yes. But I was simply asking whether, in a given row, a flight can go back and forth between two of your desired destinations more than once, i.e. is:

    NRK to MSF to NRK to MSF to NRK

    possible?

    Or can your results only ever be 1, i.e. NRK to MSF (or perhaps the reverse MSF to NRK) or 2, i.e. NRK to MSF to NRK (or perhaps the reverse MSF to NRK to MSF)?

    Remember: we might not be on the same level of knowledge as you when it comes to this subject matter!

    Regards

  15. #15
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    @XOR LX
    Sorry, I do get a little ahead of myself. Yes the results can be more than just one. The first example needs to produce a value of 4.
    Thanks for hanging in there with me!

  16. #16
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Countif(s): Need to properly count a flight plan

    Quote Originally Posted by 0311 Hesco View Post
    @XOR LX
    Sorry, I do get a little ahead of myself. Yes the results can be more than just one. The first example needs to produce a value of 4.
    Thanks for hanging in there with me!
    No worries!

    One final question (hopefully!): are you willing to change your layout very slightly so that, for example, you put NRK in W2 and MSF in W3, instead of these mixed strings that you have at the moment?

    Regards

  17. #17
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    The first example you had on post #14, thanks

  18. #18
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Absolutely! I have no problem with that!

  19. #19
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Countif(s): Need to properly count a flight plan

    Can I just check some of your desired results?

    Row 6: SBZ/NRK you have 0 as your expected result. Why is it not 1?
    Row 7: SBZ/MSF you have 0 as your expected result. Why is it not 1?
    Row 11: SBZ/NRK you have 0 as your expected result. Why is it not 1?
    Row 12: SBZ/MSF you have 1 as your expected result. Why is it not 2?

    Regards

  20. #20
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Internet Excel BEAST, lol I humbly explain...
    It is late over here and I am tired. Yes, they should be what you showed. My apologies, keep rocking the brain cells.

  21. #21
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    So would this be a countif formula or am I looking at something else?

  22. #22
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Anybody? Somebody?

  23. #23
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Well I have come up with a partial solution. I broke down the flight plan as was able to create a separate chart on another sheet and then use countifs to handle the criteria; Ex: msf-sbz-nrk, to: msf-sbz; sbz-nrk etc. That works for everything EXCEPT when there is a flight needing to be tracked that does not go directly to one of the airports being recorded. Ex: msf-fsl-sbz. This example still needs to count as 1. Any Ideas? @X0R LX

  24. #24
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Countif(s): Need to properly count a flight plan

    Can you try this array formula** in W4:

    =IF(OR(COUNTIF($D4:$R4,W$2:W$3)=0),0,SUM(0+(FREQUENCY(IF($D4:$R4=W$2,COLUMN($D4:$R4)),IF($D4:$R4=W$3,COLUMN($D4:$R4)))>0),0+(FREQUENCY(IF($D4:$R4=W$3,COLUMN($D4:$R4)),IF($D4:$R4=W$2,COLUMN($D4:$R4)))>0))-1)

    based on the assumption that you have incorporated the changes to your layout as I suggested in post #16?

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Last edited by XOR LX; 08-28-2014 at 04:48 AM.

  25. #25
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    I don't know how people like you do it. I am so very impressed. Thank you very much. I will consider this solved, but I do have one more caveat. My boss just said earlier today that he wants to track msf-nrk seperately from nrk-msf. Is this possible? Like I said, you have been more help to me than I deserve and it's OK if you can't!

    Thanks again!

  26. #26
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Countif(s): Need to properly count a flight plan

    No worries!

    Could I ask you to re-attach a workbook with some new examples and your expected results in each case, just to clarify what you mean by your latest request?

    Cheers

  27. #27
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Air Movement Tracker.xlsx
    OK, this is the updated book.
    My expected results in W13 and X13 would be 1 and 1. That way it shows that there was one leg (nrk-msf) and one leg (msf-nrk)

    Also please check the arithmetic on rows 4,5,and 6. In Row 4, it seems to be double counting a stop.
    Thanks again!

  28. #28
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Countif(s): Need to properly count a flight plan

    Quote Originally Posted by 0311 Hesco View Post
    Also please check the arithmetic on rows 4,5,and 6. In Row 4, it seems to be double counting a stop.
    I'll have a look at your new requirement soon.

    But can you first clarify what you mean by the above? Why do you mention rows 4, 5 and 6, yet then only point out a potential issue with one of those rows? And why is it wrong? Why do I need to look at rows 5 and 6?

    You need to be a bit more forthcoming with your replies: explain what your expected result is, why that is the case, and how that differs from the result my formula gives.

    Regards

  29. #29
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    OK.
    My expected result for W4:AB30 is to have each column specify how many times that the listed leg occurred in the flight in the order that is listed above that column.
    Ex. for W2,3 it is listed nrk then msf below. That column should only count the number of times that the flight flew a nrk to msf leg.
    for X2,3 it is listed msf then nrk below. That column should only count the number of times that the flight flew a msf to nrk leg.

    Disregard the arithmetic comment. I didn't realize the formula was capable of calculating "sbz-msf-nrk" as a sbz-nrk tally in addition to sbz-msf. That's great!

    The formula works the way it is needed to except for the aforementioned. Thank you very much!

  30. #30
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    Oops. Double post.

  31. #31
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Countif(s): Need to properly count a flight plan

    Ok. But just to clarify: you only want a different set of calculations for the pair NRK/MSF and MSF/NRK?

    It's just that in your attachment you've also changed the column headers so that you now have separate listings for MSF/SBZ and SBZ/MSF as well as for SBZ/NRK and NRK/SBZ.

    Can you clarify why?

    Regards

  32. #32
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    I just added columns so that it could be changed to what I asked above.

    Not exactly sure what you mean about different set of calculations. The formula you gave me works, but due to the new caveat, it needs to have two similar formulas but just separate the msf-nrk and the nrk-msf. Does that help? Not very good at describing this am I? lol

  33. #33
    Registered User
    Join Date
    08-26-2014
    Location
    Pakistan for now
    MS-Off Ver
    2010
    Posts
    23

    Re: Countif(s): Need to properly count a flight plan

    I am just about stumped on this. Looks like it's going to have to be a manual entry form after all. lol

+ 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. Replies: 0
    Last Post: 03-26-2014, 05:23 AM
  2. MLM matrix plan plan 4x4 coding/formula
    By ncsvapi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-03-2013, 08:23 AM
  3. Replies: 10
    Last Post: 05-11-2012, 02:14 AM
  4. Replies: 2
    Last Post: 01-29-2007, 06:37 PM
  5. Pages Count; Plan B
    By Rookie 1st class in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-21-2005, 03:55 PM

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