+ Reply to Thread
Results 1 to 8 of 8

Urgently trying to count unique pairs between 2 columns of text

  1. #1
    Registered User
    Join Date
    09-03-2016
    Location
    Dublin
    MS-Off Ver
    7
    Posts
    4

    Urgently trying to count unique pairs between 2 columns of text

    Hi there,

    I have 2 columns of text which include the origins and destinations of an airline and I want to count the number of unique routes (ie. A to B and B to A should count as one).

    If the network was simple, and the destinations for each airport were the same as its origin airports, it's simple (I just count the number of total routes and halve it). But in this case, an airport "A" might have a flight to "B" and then the plane goes to "C" before returning to "A" - so I can't assume that "A" and "B" connect in both directions.

    Can anyone help? Would be really appreciated

  2. #2
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Urgently trying to count unique pairs between 2 columns of text

    I think you'll need to attach a sample of your data.

    Usually with things like this it's easiest to just join the values together to create unique strings to count on.

  3. #3
    Registered User
    Join Date
    09-03-2016
    Location
    Dublin
    MS-Off Ver
    7
    Posts
    4

    Re: Urgently trying to count unique pairs between 2 columns of text

    Hi @echopassenger,

    Hopefully image is attached. The list is a LOT longer than the attached example, but it describes the issue well. Note that Airport B flies to C, but Airport C doesn't fly to B. I want to be able to count all the unique routes (eg. in this example, there are 9 rows of data and 8 unique routes because A-B and B-A should be counted as one)

    excel.png
    Attached Images Attached Images

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

    Re: Urgently trying to count unique pairs between 2 columns of text

    Many members are unable to see images in the *.png format due to forum compatibility issues with some browsers.

    If you need to post an image post it in the *.jpg format.

    Even better than posting images... post a SMALL sample file. That way we can test solutions directly in the file with the relevant data.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Urgently trying to count unique pairs between 2 columns of text

    Sorry for the delay, had to step away for a short time.

    Example attached.

    In columns D and E I have joined the Airport and Destination values left-to-right and right-to-left.
    In columns F and G I have added counts over each range above.
    In column H I have added an if statement to give a 1 if the sum of the above counts is 1 (i.e. first/only occurence)

    In joining the Airport and Destination values I have added a LOWER function to compensate for any slight differences in grammar.

    I must admit I did this quickly, but I think the only issue you would find with this is if an Airport and Destination are the same i.e. Airport A to Airport A, but I imagine that would be an unlikely flight!
    Attached Files Attached Files
    Last edited by EchoPassenger; 09-03-2016 at 02:48 PM.

  6. #6
    Registered User
    Join Date
    09-03-2016
    Location
    Dublin
    MS-Off Ver
    7
    Posts
    4

    Re: Urgently trying to count unique pairs between 2 columns of text

    Hi @echopassenger,

    This is EXACTLY what I was looking for and is working perfectly. Thanks very very much for your help, your input has saved me hours of wasted time and made this task a whole lot easier!

    Thanks!!

  7. #7
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Urgently trying to count unique pairs between 2 columns of text

    No problem, good luck with the rest of your work.

  8. #8
    Registered User
    Join Date
    09-03-2016
    Location
    Dublin
    MS-Off Ver
    7
    Posts
    4

    Re: Urgently trying to count unique pairs between 2 columns of text

    Hi @EchoPassenger,

    I was hoping to ask you for one more morsel of advice... basically I have 2 datasets.

    The first is the airports origins and destinations of Airline A and the number of seats flown on these, the second is the same for Airline B.

    I then create two further datasets by assigning a city to each of Airline A and B's airports.

    By using your tricks from your spreadsheet above, I have managed to calculate the presence of Airline B on Airline A's airport network when the two are flying to the same airports (using a match function to see if a match is true, and then if it is just taking in the number of seats that Airline A flies on that route; adding all these true matches and getting that as a percentage of overall seats flown).

    However, when I have cities, I find regularly more than one match (eg. say Airline A flies from 3 airports in London into 2 airports in Milan and Airline B flies from all 4 airports in London into all 3 airports in Milan). In these cases, my function will only return the figure from the first incidence where "London" and "Milan" matched but not the second or third, etc.

    So basically I was wondering would you be able to advise on how I can get my matching function to return the second and third incidences of matching (rather than the first repeatedly)... or indeed whether I should just find a way of tallying up all the times that Airline A flies from simply "London" into "Milan" (the problem with this procedure is that the body of data is quite significant).

    Thanks for any help!!

+ 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] Count pairs of values in adjacent columns (either way around)
    By Alfie101 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-23-2016, 03:50 AM
  2. Count unique text from multiple columns concatenated w/ one column
    By lopez235 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-01-2015, 08:54 PM
  3. Need unique count of text from multiple columns by category
    By lopez235 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-01-2015, 11:26 AM
  4. [SOLVED] Count Unique Pairs of Excel Entries Based on Criteria
    By DonFord81 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-22-2013, 01:12 PM
  5. Count number of pairs between 2 columns
    By Johnald in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-09-2013, 06:46 PM
  6. Replies: 0
    Last Post: 01-29-2012, 12:00 PM
  7. Replies: 4
    Last Post: 07-20-2011, 09:20 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