+ Reply to Thread
Results 1 to 17 of 17

Counting Unique Variables WITH Exceptions

  1. #1
    Registered User
    Join Date
    06-26-2013
    Location
    Ypsilanti, MI
    MS-Off Ver
    Excel 2010
    Posts
    9

    Counting Unique Variables WITH Exceptions

    I'm trying to write a function that counts the number of unique variables there are in a column including spaces. My current equation is as follows..

    =SUM(IF(FREQUENCY(IF(LEN('ESX Hosts'!H:H)>0,MATCH('ESX Hosts'!H:H,'ESX Hosts'!H:H,0),""), IF(LEN('ESX Hosts'!H:H:'ESX Hosts'!H:H)>0,MATCH('ESX Hosts'!H:H,'ESX Hosts'!H:H,0),""))>0,1))
    I need it to only count the number of unique entries if it matches the B column's text in the ESX Hosts sheet. So I think I need to create another IF function. I need to read ('ESX Hosts'! B:B. "Blah blah").

    I just don't know how to integrate that with the other function. Help is much appreciated!!

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

    Re: Counting Unique Variables WITH Exceptions

    Post an excel example, without confidentional information.

    Please also add the desired (expected) result.
    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
    06-26-2013
    Location
    Ypsilanti, MI
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting Unique Variables WITH Exceptions

    Untitled.png

    The function would count how many times a variable occurs only once - even if repeated while also not counting blanks. It also counts only for when text in the color's column says the text for the actual color. The same function would be used for each different color.

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

    Re: Counting Unique Variables WITH Exceptions

    I try again post an excel file, without confidentional information, also add the desired (expected) result.

  5. #5
    Registered User
    Join Date
    06-26-2013
    Location
    Ypsilanti, MI
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting Unique Variables WITH Exceptions

    Quote Originally Posted by oeldere View Post
    I try again post an excel file, without confidentional information, also add the desired (expected) result.
    Here is a very basic sample excel file. My equation works in counting ALL unique values but I only need it to count when a column includes a certain text.

    Example.xlsx

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

    Re: Counting Unique Variables WITH Exceptions

    I don't understand the result, so i try it with an pivot table.
    Attached Files Attached Files

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

    Re: Counting Unique Variables WITH Exceptions

    Try this...

    On the Result sheet...

    A1 = Blue
    A2 = Red
    A3 = Yellow

    Enter this array formula** in B1 and copy down:

    =SUM(IF(FREQUENCY(IF(Info!A$1:A$12=A1,IF(Info!B$1:B$12<>"",MATCH(Info!B$1:B$12,Info!B$1:B$12,0))),ROW(Info!B$1:B$12)-ROW(Info!B$1)+1),1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    You should avoid using entire columns as range references in array formulas.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  8. #8
    Registered User
    Join Date
    06-26-2013
    Location
    Ypsilanti, MI
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting Unique Variables WITH Exceptions

    Still haven't been able to get the solution. I attached a more in depth demo of the sheet I'm working with.My comment box in the REPORT tab mentions what I need to do.

    Thanks again to whomever can help. This is giving me a serious headache.

    You should avoid using entire columns as range references in array formulas.
    The reason I'm using whole columns is because this sheet is being continually updated with added rows daily. I could just throw in a high enough number, though.

    pjd2011 Demo.xls

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

    Re: Counting Unique Variables WITH Exceptions

    Sorry, your file is too big. I won't download files >50kb.

  10. #10
    Registered User
    Join Date
    06-26-2013
    Location
    Ypsilanti, MI
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting Unique Variables WITH Exceptions

    Quote Originally Posted by Tony Valko View Post
    Sorry, your file is too big. I won't download files >50kb.
    Ok, I removed a lot of the information to shrink it down to just the bare basics.

    pjd2011 Demo.xlsx

  11. #11
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Counting Unique Variables WITH Exceptions

    Part of your conditions are contradictory. "The function would count how many times a variable occurs only once - even if repeated" How can something only occur once and be repeated?

    My best guess at what you want is as follows:

    On the Result tab change the entries in column A to Blue, Red, Yellow. Enter this formula where you want the answer. (Column B?) and copy down the length of your data.

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


    Another way of looking at this enter this formula instead which will count all Duplicate combinations as 1 and count each unique value (up to 4) as 1.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by newdoverman; 06-27-2013 at 10:16 AM.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

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

    Re: Counting Unique Variables WITH Exceptions



    Sorry, but your data doesn't seem to match your description and I don't understand your comments.

    On the Report sheet you have "categories" of Blue, Red, Green, and Yellow but I don't see any of those categories on the Main sheet.

  13. #13
    Registered User
    Join Date
    06-26-2013
    Location
    Ypsilanti, MI
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting Unique Variables WITH Exceptions

    Quote Originally Posted by Tony Valko View Post


    Sorry, but your data doesn't seem to match your description and I don't understand your comments.

    On the Report sheet you have "categories" of Blue, Red, Green, and Yellow but I don't see any of those categories on the Main sheet.
    Sorry about that. I just came up with those categories as dummy variables. Didn't think that one through. I think I used the numbers 1-7 as variables instead of the colors.

  14. #14
    Registered User
    Join Date
    06-26-2013
    Location
    Ypsilanti, MI
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting Unique Variables WITH Exceptions

    Quote Originally Posted by newdoverman View Post
    Part of your conditions are contradictory. "The function would count how many times a variable occurs only once - even if repeated" How can something only occur once and be repeated?]
    So if the variable D121 showed up 5 different times it would be counted only one time is what I was trying to convey. The equation I need would also add the function of only counting data that included a certain text in a column.

  15. #15
    Registered User
    Join Date
    06-26-2013
    Location
    Ypsilanti, MI
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting Unique Variables WITH Exceptions

    I, again, updated the Excel sheet to the accurate information and a more detailed explanation of what I am looking for. Please continue to try as my brain is fried trying!! Thank you!

    pjd2011 Demo.xlsx

  16. #16
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Counting Unique Variables WITH Exceptions

    It would have been nice to know the real problem instead of being presented with a problem that changes into something completely different.

    Good luck

  17. #17
    Registered User
    Join Date
    06-26-2013
    Location
    Ypsilanti, MI
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Counting Unique Variables WITH Exceptions

    Quote Originally Posted by newdoverman View Post
    It would have been nice to know the real problem instead of being presented with a problem that changes into something completely different.

    Good luck
    I feel as though I have been clear in showing what the problem is. I had to go through and delete/alter much of the information I'm working on as it is not public. I apologize that my information is not up to par, I figured this community would be understanding.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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