Results 1 to 7 of 7
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Crosstab Dummy

    Really newbie question here. I can't get my mind around it.

    How do I get the cross tab to recognize only the first UniqueName where Parent is equal?



    Click image for larger version. 

Name:	UniqueName.PNG 
Views:	14 
Size:	5.8 KB 
ID:	31951

    Crosstab.zip
    Attached Files Attached Files

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    If I've understood you correctly you want to see this.

    Click image for larger version. 

Name:	Capture.PNG 
Views:	13 
Size:	3.4 KB 
ID:	31954

    If so, you don't want a crosstab - use an aggregate query instead

    Click image for larger version. 

Name:	Query.PNG 
Views:	13 
Size:	7.1 KB 
ID:	31955

    Code:
    SELECT Mounts.UniqueName, First(Mounts.Unique) AS FirstOfUnique, Mounts.ParentFROM Mounts
    GROUP BY Mounts.UniqueName, Mounts.Parent;
    However, bear in mind that the first record may not be what you were expecting - see the 2nd record above
    An alternative to consider is to use Min instead of First

    Code:
    SELECT Mounts.UniqueName, Min(Mounts.Unique) AS MinOfUnique, Mounts.ParentFROM Mounts
    GROUP BY Mounts.UniqueName, Mounts.Parent;
    which gives

    Click image for larger version. 

Name:	Capture2.PNG 
Views:	12 
Size:	3.5 KB 
ID:	31956
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    ridders52,
    That works for me so far and is simpler. Min and First Seem to work the same for me. How do I weed out the 117's that only have 1 radio from going into first/min or last/max, but not both?

    Single 117's meet both criteria technically.

    Thanks!!

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Quote Originally Posted by Thompyt View Post
    ridders52,
    That works for me so far and is simpler. Min and First Seem to work the same for me. How do I weed out the 117's that only have 1 radio from going into first/min or last/max, but not both?

    Single 117's meet both criteria technically.

    Thanks!!
    Not sure what you mean?
    Perhaps use unique records in your query - SELECT DISTINCT
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Crosstab.zip

    I made 2 Queries in the attached db and deleted 1 117 out from the Data table.

    If you run the queries you will notice the 117 with unique = 12319 showing up in both. I tried first/Min and last/Max with the same outcome. How would I remove 12319 from 1 of the queries?

    Other than putting "<>12319" in the unique Criteria.


    Kind of like IIF([LastMounts].[MinOfUnique] <> [FirstMounts].[MixOfUnique], [LastMounts].[MinOfUnique], "")

    I think I found it, but is there a more eloquent way?

    Code:
    SELECT LMounts.UniqueName, IIf([MinOfUnique]=[MaxOfUnique],"",[MaxofUnique]) AS [Second], LMounts.ParentFROM FirstMounts INNER JOIN LMounts ON (FirstMounts.Parent = LMounts.Parent) AND (FirstMounts.UniqueName = LMounts.UniqueName)
    WHERE (((IIf([MinOfUnique]=[MaxOfUnique],"",[MaxofUnique])) Is Not Null));
    Thanks

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Sorry but I'm not at all clear what you're trying to do but your suggested query wouldn't compile.
    Corrected version below:

    Code:
    SELECT LastMounts.UniqueName, IIf([MinOfUnique]=[MaxOfUnique],'',[MaxofUnique]) AS [Second], LastMounts.Parent FROM FirstMounts INNER JOIN LastMounts ON (FirstMounts.Parent = LastMounts.Parent) AND (FirstMounts.UniqueName = LastMounts.UniqueName)
    WHERE (((IIf([MinOfUnique]=[MaxOfUnique],'',[MaxofUnique])) Is Not Null));
    Which gives this result

    Click image for larger version. 

Name:	Capture3.PNG 
Views:	7 
Size:	4.7 KB 
ID:	31969

    Is that what you want?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Yes that's what I was going for, My version for text, yours for #'s
    I made another query with the same fields and used this:

    IIf([MinOfUnique_id]=[MaxOfUnique_id],"",[MinofUnique_id])

    Thanks

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

Similar Threads

  1. How to create a "dummy" field name
    By accessmatt in forum Access
    Replies: 1
    Last Post: 04-28-2015, 11:20 AM
  2. Using IIF statements to dummy columns
    By Toble in forum Queries
    Replies: 4
    Last Post: 02-24-2015, 04:50 PM
  3. Creating Dummy Fields in a Report
    By Whehir in forum Reports
    Replies: 2
    Last Post: 06-13-2012, 05:45 PM
  4. Replication. (Master and Dummy DBs)
    By OrangePie in forum Access
    Replies: 1
    Last Post: 07-28-2011, 03:10 PM
  5. Replies: 3
    Last Post: 04-10-2010, 10:22 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