Results 1 to 6 of 6
  1. #1
    bms is offline Novice
    Windows Vista Access 2000
    Join Date
    Oct 2010
    Posts
    3

    Question Count occurrences of unique values cross fields


    Hi,
    I have a table like so, and I am looking for the number of unique values in fields in access
    I used the following in excel but not sure how to accomplish the same in access query

    SUM(IF(FREQUENCY(Table1[@[D1]:[D5]],Table1[@[D1]:[D5]])>0,1))

    Thanks much


    D1 D2 D3 D4 D5 Unique
    1 2 3 4 5 5
    1 1 1 2 3 3
    2 2 2 2 2 1
    2 2 2 3 3 2
    4 4 4 5 6 3

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This is not a normalized data structure. Would be fairly easy with normalized structure.

    Options:

    1. custom VBA function.

    2. normalize the data structure so queries can accomplish the count - a UNION query can manipulate the data into a normalized structure then use that query as the source for subsequent queries
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    bms is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2010
    Posts
    3
    do you mean normalize like in 1/0 ? could you kindly give me an example
    Thanks again

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What does 1/0 mean?

    Normalized data structure:
    Category Data
    D1 1
    D2 2
    D3 3
    D4 4
    D5 5
    D1 1
    D2 1
    D3 1
    D4 2
    D5 3

    A UNION query could generate that structure. There is no wizard for UNION, must type or copy/paste in SQL View of query builder. Limit of 50 SELECT lines.

    SELECT "D1" AS Category, D1 As Data FROM tablename
    UNION SELECT "D2", D2 FROM tablename
    UNION SELECT "D3", D3 FROM tablename
    UNION SELECT "D4", D4 FROM tablename
    UNION SELECT "D5", D5 FROM tablename;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    bms is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2010
    Posts
    3
    got it, thank you so so much for the quick respond !

    1/0 as in a yes/no field

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Access uses -1/0 for Yes/No.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-24-2014, 02:19 PM
  2. Count Unique Values in a Category
    By fionny in forum Queries
    Replies: 2
    Last Post: 06-28-2013, 02:28 AM
  3. Count Unique Fields and then get Average
    By Kirsti in forum Queries
    Replies: 5
    Last Post: 02-19-2012, 07:25 PM
  4. Unique Values and Boolean Fields
    By Triad in forum Forms
    Replies: 1
    Last Post: 07-15-2010, 06:28 PM
  5. Count of Unique Values
    By vsmk in forum Queries
    Replies: 2
    Last Post: 03-14-2010, 12:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums