Results 1 to 6 of 6
  1. #1
    racefan91 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Sep 2013
    Posts
    57

    Remove blanks from a crosstab query in another query

    I have a table with movie ratings where the name of the movie is in the first column and the second column is the rating for the song. I want to create a query where all the different ratings are the column headings and then the movie name goes in the column of how it rated. When I created my crosstab query there are blank cells in each row for a specific movie except the column that has the movie title. Is there a way to make a query that gets rid of all the blank cells?



    This is how the crosstab looks
    Click image for larger version. 

Name:	Crosstab.jpg 
Views:	21 
Size:	14.9 KB 
ID:	52551


    This is what I want to achieve
    Click image for larger version. 

Name:	Query.jpg 
Views:	19 
Size:	10.1 KB 
ID:	52550

  2. #2
    madpiet is offline Expert
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    565
    Quote Originally Posted by racefan91 View Post
    I have a table with movie ratings where the name of the movie is in the first column and the second column is the rating for the song. I want to create a query where all the different ratings are the column headings and then the movie name goes in the column of how it rated. When I created my crosstab query there are blank cells in each row for a specific movie except the column that has the movie title. Is there a way to make a query that gets rid of all the blank cells?

    This is how the crosstab looks
    Click image for larger version. 

Name:	Crosstab.jpg 
Views:	21 
Size:	14.9 KB 
ID:	52551


    This is what I want to achieve
    Click image for larger version. 

Name:	Query.jpg 
Views:	19 
Size:	10.1 KB 
ID:	52550
    Got some data? I'm not 100% sure how you'd put non-numeric data in the VALUES section. If it were Excel or PowerBI, I'd do something like CONCATENATEX('Movies',[MovieTitle],", ") in there. In a word, I wouldn't do it Abscess. The pus just gets everywhere. No really, it's super simple in Excel. I guess you'd just use CrLf as the delimiter.

    Movie List:=CONCATENATEX('Table1_1',[Movie]," ",[Movie])

    (well, instead of the space " " I'm using.

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,820
    Hi
    Are you able to upload a copy of the database?

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    I'm not 100% sure how you'd put non-numeric data in the VALUES section
    by using first/last/min/max

    @racefan - would need to see your table and crosstab sql to see if it could be solved in access

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Right, what is the GROUP BY parameter that these movie names would be associated with? A CROSSTAB requires 3 fields so what is your SQL?

    Provide db or build a table in post (click Go Advanced to get the table builder toolbar). Can even copy/paste records.
    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.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You must be using unique record ID field as RowHeader to accomplish that CROSSTAB. That would certainly result in a lot of blanks. Getting the output you desire is tricky. One approach uses DCount() domain aggregate function to calculate a RowHeader field.

    TRANSFORM First(MovieName) AS FirstMovieName
    SELECT Val(DCount("*","Movies","ID<=" & [ID] & " AND Rating=" & [Rating])) AS R
    FROM Movies
    GROUP BY Val(DCount("*","Movies","ID<=" & [ID] & " AND Rating=" & [Rating]))
    PIVOT Movies.Rating IN(10,9,8,7,6,5,4,3,2,1);

    R 10 9 8 7 6 5 4 3 2 1
    1 Movie1 Movie4 Movie2 Movie3
    2 Movie5




    Movie6


    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. Query with Blanks and Non-Blanks
    By getalinks in forum Queries
    Replies: 14
    Last Post: 05-21-2015, 03:30 PM
  2. Replies: 1
    Last Post: 08-01-2013, 08:47 AM
  3. Replies: 6
    Last Post: 06-14-2012, 03:39 PM
  4. Conatenate fields and also remove blanks
    By Rubijon in forum Reports
    Replies: 3
    Last Post: 10-23-2011, 05:29 PM
  5. Fill in blanks from another table
    By HectorH in forum Queries
    Replies: 1
    Last Post: 08-26-2011, 05:13 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