Results 1 to 3 of 3
  1. #1
    RAJESHKUMAR R is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    48

    How to Put Criteria in Crosstab Query Value Field

    Dear Friends,

    In the attached database I have a Crosstab Query Named as “Result”!



    Right Now, it is giving a complete list of items. Instead, I would want result table to display, where filed value is Not Equal to Zero (i.e. Positive Value or Negative Value).

    And, where the field value is blank or Zero respective PN or Month should not be appeared in the Result Table!

    Kindly help me with the same!

    Thanks & Regards,
    Rajeshkumar R
    Attached Files Attached Files

  2. #2
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Create an aggregate query where you group by product and YrMo and do a sum of Qty with criteria <>0.
    Save it and then create your crosstab based on that

    Note that the order will be alphabetical as YrMo is a text string. This means Apr-18 will be the first column
    There are ways around that if you want the data in calendar month order
    You can't specify column headers unless you are happy for all columns to appear even if blank.
    Another solution is to use a numerical version of YrMo e.g Apr-18=1804.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Continued from https://www.accessforums.net/showthread.php?t=70538

    Suggestion was to calculate YYYY-MM, not MMM-YY.

    Can't exclude PN from listing in CROSSTAB if it has data for any date. A month will not have a column if there is no PN for that date. The nature of CROSSTAB is to have blank cells. The zeros in the CROSSTAB are the result of calculating records with positive and negative values. The net result is 0. It is real data.

    Consider all-in-one sql:

    TRANSFORM First(Query1.SumOfQty) AS FirstOfSumOfQty
    SELECT Query1.Product
    FROM (SELECT Q1.Product, Q1.YrMo, Sum(Q1.Qty) AS SumOfQty
    FROM (SELECT Product, Qty, CRD, Format([CRD], "MMM-YY") AS YrMo, "FC" AS Cat FROM Forecast
    UNION ALL SELECT Product, Qty*-1, CRD, Format([CRD], "MMM-YY") , "FO" FROM Firmorder) AS Q1
    GROUP BY Q1.Product, Q1.YrMo
    HAVING (((Sum(Q1.Qty))<>0))) AS
    Query1
    GROUP BY Query1.Product
    PIVOT Query1.YrMo;
    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. Crosstab query criteria
    By venu in forum Tutorials
    Replies: 3
    Last Post: 08-21-2014, 11:19 AM
  2. crosstab query criteria
    By Sharron in forum Queries
    Replies: 3
    Last Post: 12-15-2011, 04:31 AM
  3. crosstab query (criteria does not work)
    By Rich P in forum Access
    Replies: 1
    Last Post: 02-15-2011, 11:40 AM
  4. crosstab query (criteria)
    By Rich P in forum Queries
    Replies: 1
    Last Post: 02-14-2011, 08:40 PM
  5. Criteria in Crosstab Query
    By wasim_sono in forum Queries
    Replies: 1
    Last Post: 12-12-2006, 05:14 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