+ Reply to Thread
Results 1 to 10 of 10

Count paired values within a single row or column

  1. #1
    Registered User
    Join Date
    10-07-2018
    Location
    Bordeaux, France
    MS-Off Ver
    2010
    Posts
    8

    Count paired values within a single row or column

    Hello,

    I want a formula for counting paired values (numeric or non-numeric) within a single row or column, irrespective of order. Searching for an answer has only given me COUNTIF formulae for counting pairs between two or more columns, but I feel there should be some kind of an array solution...?

    In the example below, each Pair (A, B, or C) in the first row corresponds to one of two values in the Choice row (A = 2 or 3, B = 4 or 5, C = 6 or 7).

    Within the Choice row, I want to count the total number of times, for each value pair, both "choices" were selected. Another way of putting this, in terms of this example, would be "How many instances of the value 2 have a corresponding value 3 within the same row?".

    Finally, I want to sum these totals.

    Excel count question.png

    Hence, the answer to the above example is:
    Pair A = 2 (the value 2 appears 6 times, but has a corresponding value 3 only twice).
    Pair B = 2 (the value 4 appears 5 times, but has a corresponding value 5 only twice).
    Pair C = 4 (the value 6 appears 4 times and each instance has a corresponding value 7).
    Total = 8.

    Hope that all makes sense and someone can help. Thanks very much!
    Last edited by metaphysiology; 06-04-2019 at 10:17 AM.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Count paired values within a single row or column

    Just set up criteria range.

    Ex: in AA3:AA5, A, B, C
    In AB3:AB5, 2, 4, 6
    In AC3:AC5, 3, 5, 7.

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


    Copy down.
    In AD6: SUM(AD3:AD5)
    Attached Files Attached Files
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    10-07-2018
    Location
    Bordeaux, France
    MS-Off Ver
    2010
    Posts
    8

    Re: Count paired values within a single row or column

    Thanks for the input. That criteria range solution works for this one example, but it would get quite cumbersome if deployed across many different such examples on already crowded data tables.

    No formula solution ideas?

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Count paired values within a single row or column

    What's considered "Pair" and where is that definition stored?

    If you have access to PowerPivot (Data model and DAX) I'd perform calculation using DAX measure.

    Alternately you could add helper column.

    But then, I know nothing of your workbook set up. If you need more specific help, I'd recommend you upload sample workbook that mirror your actual workbook set up, with desensitized info.

  5. #5
    Registered User
    Join Date
    10-07-2018
    Location
    Bordeaux, France
    MS-Off Ver
    2010
    Posts
    8

    Re: Count paired values within a single row or column

    The "Pair" row is incidental to the solution I was looking for (though, that solution may not exist).

    In it's simplest pseudocode form: Within a given row/column of values, how many instances of X have a corresponding Y somewhere within the same row/column?

    I'm not familiar with PowerPivot, I may look in that direction; thanks on that score too!

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,885

    Re: Count paired values within a single row or column

    Oh, as FYI this could also be done using PowerQuery Add-in.

    In both PowerPivot & PowerQuery, data should be transposed to Flat table structure (Pair, Choice as header row, data growing length wise).

    Off top of my head, can't think of dynamic formula solution for this.

  7. #7
    Registered User
    Join Date
    10-07-2018
    Location
    Bordeaux, France
    MS-Off Ver
    2010
    Posts
    8

    Re: Count paired values within a single row or column

    While still grateful for CK76's help, no one has any dynamic formula solutions in mind?

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,554

    Re: Count paired values within a single row or column

    Perhaps this will be of help.
    Z1:AB1 are populated with the 'pair' identifiers A, B and C respectively.
    Z2:AB2 are populated using: =MIN(COUNTIFS($B2:$X2,INDEX($B2:$X2,MATCH(Z1,$B1:$X1,0))),COUNTIFS($B1:$X1,Z1,$B2:$X2,"<>"&INDEX($B2:$X2,MATCH(Z1,$B1:$X1,0))))
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  9. #9
    Registered User
    Join Date
    10-07-2018
    Location
    Bordeaux, France
    MS-Off Ver
    2010
    Posts
    8

    Re: Count paired values within a single row or column

    Sorry to reply so late. This looks good JeteMc, thank you. I'll play around with it in my other examples and make sure it returns correct expected results everywhere.

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,554

    Re: Count paired values within a single row or column

    You're Welcome and thank you for the feedback. If you should find the solution works with the other examples, please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.

+ 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. Count paired numbers in two columns
    By excelsior22 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-30-2018, 08:51 PM
  2. [SOLVED] distribution of values from single cell to multiple cells in single column
    By WhatsGig in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 08-29-2017, 02:30 PM
  3. Replies: 3
    Last Post: 12-28-2015, 04:58 PM
  4. [SOLVED] Matching Paired Values and Counting
    By CWatsonJr in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 10-18-2015, 09:48 PM
  5. Filling a matrix from paired values in another sheet
    By guest2013 in forum Excel General
    Replies: 2
    Last Post: 08-17-2013, 12:02 PM
  6. I have numerous columns with a paired alphabets need a count on A
    By SAMEEP in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-21-2012, 04:53 PM
  7. [SOLVED] Total Summed Count of Numeric Repeat (Paired /Double Instance) Criteria
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-19-2006, 10:35 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