Results 1 to 3 of 3
  1. #1
    Andy.S is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2018
    Posts
    6

    Transfrom query - How to achieve output (if possible?)

    I have a requirement to take the following general format of data...

    Col A Col B Col C Col D
    A1 B1 C1 D1
    A1 B1 C1 D2
    A1 B1 C1 D3
    A2 B2 C2 D1
    A2 B2 C2 D4
    A2 B2 C2 D5
    A3 B3 C3 D2
    A3 B3 C3 D3
    A3 B3 C3 D6
    A3 B3 C3 D7

    And in essence, PIVOT the values on Col D to end up with output that looks similar to...



    Col A Col B Col C
    A1 B1 C1 D1 D2 D3
    A2 B2 C2 D1 D4 D5
    A3 B3 C3 D2 D3 D6 D7

    The values in Col D are in reality a 4 digit code, so potentially many hundreds of values altogether.

    The best I have got so far is more like...

    Col A Col B Col C D1 D2 D3 D4 D5 D6 D7
    A1 B1 C1 2 2 2
    A2 B2 C2 2 1 1
    A3 B3 C3 2 2 1 1

    But given the nature of Col D, the list of D values to the right is not good. The query has (arbitrarily) got a a count as the Aggregate on Col A, hence the numbers showing.

    So ...

    TRANSFORM COUNT(A & B & C)
    Select Distinct A, B,C
    FROM TABLE A
    GROUP BY A, B, C
    PIVOT D

    Any assistance would be great.

    Thanks.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    make a query ,Q1, of the data you want to use
    then use the query wizard, to make a Crosstab query on Q1
    pick your rows
    pick your columns
    pick your values

  3. #3
    Andy.S is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2018
    Posts
    6
    Thank you for the prompt reply, but the crosstab still appears to be a count rather than the specific values and it ends up with (in my sample) over 800 columns which the tool fails with.

    The requirement here does now have a potential option, as the 'real' query is going into some application code to ultimately produce the desired CSV report output. Speaking to the coder, he can take what I had as the first sample output (with Col D containing all the required values) and simply loop through row by row and on change of D put the output to the right and on change of Col A/B/C add a new row. It is post processing the data but probably less complex as a result.

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

Similar Threads

  1. CrossTab Query to Achieve a Cumulative Total
    By Alex_622 in forum Access
    Replies: 1
    Last Post: 10-07-2016, 07:35 AM
  2. How to achieve result without duplicates
    By punna111 in forum Queries
    Replies: 4
    Last Post: 06-15-2015, 01:44 PM
  3. How to link tables to achieve following.
    By hanns.g in forum Database Design
    Replies: 3
    Last Post: 04-01-2014, 01:58 PM
  4. How do I achieve late binding on a Chart?
    By RocketMonkey in forum Forms
    Replies: 1
    Last Post: 02-12-2013, 02:11 PM
  5. Help with Relationships and how to achieve a goal.
    By kimhuff in forum Database Design
    Replies: 8
    Last Post: 03-10-2011, 12:56 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