+ Reply to Thread
Results 1 to 12 of 12

Count the number of different values based on MULTIPLE columns

  1. #1
    Registered User
    Join Date
    12-14-2018
    Location
    Pathum Thani, Thailand
    MS-Off Ver
    Office 2016
    Posts
    6

    Count the number of different values based on MULTIPLE columns

    Hello Excel Community,

    I have a dumb question here.

    The dataset has 4 columns: province, district, village and household (in the increasing level of detailedness).

    I want to count the number of villages. In other words, I want to count the number of different triplets of (province, district, village) (a village has many household).

    It may seem to be a noob question to you all.

    Thank you a lot for all your time on my question.

    For clarification, the dataset is like this:
    A b c d
    province, district, village, Households
    p1 d1 v1 h11

    p2 d2 v2 h21
    p2 d2 v2 h21

    p3 d3 v3 h31
    p3 d3 v3 h31

    p4 d41 v41 h41
    p4 d41 v41 h42

    p4 d42 v42 h43

    Then there are only 5 triplets of (p,d,v)={(1,1,1),(2,2,2),(3,3,3),(4,41,41),(4,41,42)}
    There are some duplicates of (p,d,v).
    Last edited by Tho Pham; 12-14-2018 at 03:27 PM.

  2. #2
    Registered User
    Join Date
    10-30-2018
    Location
    London
    MS-Off Ver
    excel 2010
    Posts
    53

    Re: Count the number of different values based on MULTIPLE columns

    Hi Tho,

    finding it hard to understand what you mean, im sorry.
    you have:

    [ATTACH]
    602196
    [/ATTACH]

    is this right, if so not please ammend for clarity. thanks
    i hope you see my meaning, this window is corrupting my table once i publish thread, so do excuse me, even better if you have a small file with your requirement you can post it on here.
    Attached Images Attached Images
    Last edited by Brian Itotia; 12-14-2018 at 03:37 PM.

  3. #3
    Registered User
    Join Date
    12-14-2018
    Location
    Pathum Thani, Thailand
    MS-Off Ver
    Office 2016
    Posts
    6

    Re: Count the number of different values based on MULTIPLE columns

    Thank you a lot for your perusal, Brian. Just edited my post.

  4. #4
    Registered User
    Join Date
    10-30-2018
    Location
    London
    MS-Off Ver
    excel 2010
    Posts
    53

    Re: Count the number of different values based on MULTIPLE columns

    pleasure Tho,
    my assumption is you would like to count something based on a certain criteria?
    please clarify.
    apologies for delayed uptake, its been a long day but im happy to review

  5. #5
    Registered User
    Join Date
    12-14-2018
    Location
    Pathum Thani, Thailand
    MS-Off Ver
    Office 2016
    Posts
    6

    Re: Count the number of different values based on MULTIPLE columns

    I didnt even expect this quick replies from the community. It's so kind of you Brian.
    I did edit my post. I will put the calarification here again.

    For clarification, the dataset is like this:
    A b c d
    province, district, village, Households
    p1 d1 v1 h11

    p2 d2 v2 h21
    p2 d2 v2 h21

    p3 d3 v3 h31
    p3 d3 v3 h31

    p4 d41 v41 h41
    p4 d41 v41 h42

    p4 d42 v42 h43

    Then there are only 5 triplets of (p,d,v)={(1,1,1),(2,2,2),(3,3,3),(4,41,41),(4,41,42)}
    There are some duplicates of (p,d,v).

  6. #6
    Registered User
    Join Date
    10-30-2018
    Location
    London
    MS-Off Ver
    excel 2010
    Posts
    53

    Re: Count the number of different values based on MULTIPLE columns

    and you would like a count of villages for each distinct province,with a distinct district?
    Last edited by Brian Itotia; 12-14-2018 at 04:48 PM.

  7. #7
    Registered User
    Join Date
    12-14-2018
    Location
    Pathum Thani, Thailand
    MS-Off Ver
    Office 2016
    Posts
    6

    Re: Count the number of different values based on MULTIPLE columns

    Yes, Brian. I want to count the number of distinct triplets (p,d,v). It's similar to "the households in each village dont matter".

    Donno if I have made it clear enough.

  8. #8
    Registered User
    Join Date
    10-30-2018
    Location
    London
    MS-Off Ver
    excel 2010
    Posts
    53

    Re: Count the number of different values based on MULTIPLE columns

    sorry tho,
    would have loved to help but i think a sample file would be useful
    anyway i know that to do this you would require nesting the countifs in a sumproduct..i have this but tyou would have to edit to suit

    =SUMPRODUCT((1/COUNTIFS(A2:A22,A2:A22,B2:B22,B2:B22,C2:C22,C2:C22)))

    i hope this helps

  9. #9
    Registered User
    Join Date
    12-14-2018
    Location
    Pathum Thani, Thailand
    MS-Off Ver
    Office 2016
    Posts
    6

    Re: Count the number of different values based on MULTIPLE columns

    Hello Brian,

    I traced through your instructions, just made it now. Thank you so much, Brian. You are a life saver.

  10. #10
    Registered User
    Join Date
    10-30-2018
    Location
    London
    MS-Off Ver
    excel 2010
    Posts
    53

    Re: Count the number of different values based on MULTIPLE columns

    Hey Tho,

    Thats good news! Glad to hear.
    Any chance to view the finished formula as per your particular data set?


    Best
    Brian
    Last edited by Brian Itotia; 12-15-2018 at 03:33 AM.

  11. #11
    Registered User
    Join Date
    12-14-2018
    Location
    Pathum Thani, Thailand
    MS-Off Ver
    Office 2016
    Posts
    6

    Re: Count the number of different values based on MULTIPLE columns

    Brian,

    It's very similar to yours. Took time to understand what you wrote :D
    =SUMPRODUCT(1/COUNTIFS(A2:A9223,A2:A9223,B2:B9223,B2:B9223,C2:C9223,C2:C9223,D2:D9223,D2:D9223,E2:E9223,E2:E9223))

    Just add reputation to your account and will mark it as solved now.

  12. #12
    Registered User
    Join Date
    10-30-2018
    Location
    London
    MS-Off Ver
    excel 2010
    Posts
    53

    Re: Count the number of different values based on MULTIPLE columns

    Yea, it messes with notions of reality this one, you doubt its practicality the whole time youre building it until you understand it.
    As a side note, it is quite slow as it is doing a scan of everything, there is an alternative way using frequency nested in a sum product, which does it in half the time or less over huge amount of data, so if speed may be a factor for you or size of d set, I recommend explore that.
    Thanks for the rep and prompt response.
    Good luck.

+ 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: 11
    Last Post: 11-16-2017, 07:11 AM
  2. Replies: 3
    Last Post: 08-24-2017, 05:59 AM
  3. [SOLVED] Count number of occurrences based on criteria in multiple columns and rows
    By gerryger in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-22-2015, 08:13 PM
  4. [SOLVED] Find count of Unique or Duplicate Values based on Concatenated values in 2 columns
    By bdicarlo1 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-03-2014, 12:42 AM
  5. Looking up values based on a field of text/ number, multiple columns
    By engen44 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-25-2014, 09:26 AM
  6. Replies: 1
    Last Post: 03-28-2013, 01:48 PM
  7. Replies: 5
    Last Post: 04-21-2011, 05:22 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