Results 1 to 5 of 5
  1. #1
    Rustin788 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2014
    Posts
    47

    Pull Out Common Items

    Hey,

    I am trying to find a way to easily pull out items that customers purchased in common. For instance, in the example I made below I would like the results to show me that all 3 companies purchased Blue and Orange. In the actual report I am looking at 10-15 customers at a time and some customers purchase 30 different items.

    I have tried to just do it manually by looking at a cross tab but the cross tab still keeps the items groups separately so I can't tell which item all customers have purchased.

    Thanks for the help.


    Customer Item Qty
    A Blue 1
    A Orange 3
    A Yellow 4
    A Green 2
    B Blue 2
    B Orange 1
    B Red 4
    B Purple 3
    C Blue 5
    C Orange 3
    C Black 4
    C Pink 4


  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    now the count query will show, by Product:

    Row Labels Count of Customer
    Black 1
    Blue 3
    Green 1
    Orange 3
    Pink 1
    Purple 1
    Red 1
    Yellow 1


    and another will give names by product:
    Item Customer Qty
    Black C 4
    Blue A 1
    Blue B 2
    Blue C 5
    Green A 2
    Orange A 3
    Orange B 1
    Orange C 3
    Pink C 4
    Purple B 3
    Red B 4
    Yellow A 4

  3. #3
    Join Date
    Apr 2017
    Posts
    1,679
    Having table name tblTest:

    Create a saved query
    Code:
    qTestCustomers = SELECT DISTINCT t.Customer AS Customer FROM tblTest AS t;
    Create a Query
    Code:
    SELECT t.Item, COUNT(t.Customer) AS ItemCustomers
    FROM tblTest t
    GROUP BY t.Item
    HAVING COUNT(t.Customer) = (SELECT COUNT(Customer) FROM qTestCustomers);

  4. #4
    Rustin788 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2014
    Posts
    47
    Quote Originally Posted by ArviLaanemets View Post
    Having table name tblTest:

    Create a saved query
    Code:
    qTestCustomers = SELECT DISTINCT t.Customer AS Customer FROM tblTest AS t;
    Create a Query
    Code:
    SELECT t.Item, COUNT(t.Customer) AS ItemCustomers
    FROM tblTest t
    GROUP BY t.Item
    HAVING COUNT(t.Customer) = (SELECT COUNT(Customer) FROM qTestCustomers);
    Awesome, that worked. Just to make sure I understand what it is doing...

    - The qTestCustomers query is looking at my data and and giving me a list of the unique values.

    - The second query is counting the number of customers that purchased each item and then only including those that match the total number of customers in the first query.

  5. #5
    Join Date
    Apr 2017
    Posts
    1,679
    Exactly!

    Slightly changing the condition in HAVING clause, you also can get p.e. list of items which are bought at least by given percent of customers.

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

Similar Threads

  1. Replies: 2
    Last Post: 02-13-2018, 07:06 PM
  2. Counting Common Attributes
    By Brandon12 in forum Queries
    Replies: 4
    Last Post: 09-28-2017, 09:38 AM
  3. Replies: 2
    Last Post: 05-24-2016, 08:01 AM
  4. the cells that some rows have in common
    By analarana in forum Access
    Replies: 3
    Last Post: 06-11-2013, 02:33 PM
  5. Pull not one but ALL items in a query
    By Andycam in forum Queries
    Replies: 2
    Last Post: 02-06-2013, 04:35 PM

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