Results 1 to 8 of 8
  1. #1
    robnsd is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2015
    Posts
    9

    How to separate positive and negative values in a report

    I have a parameter query that brings up records for a user selected date. One of the fields in each record is amount [Amt]. [Amt] can be either a positive or negative number. I want to create a report based on the query that shows records where [Amt] is greater than zero in one column and records where [Amt] is less than zero in a second column. I know this must be simple but I can not get my head around it.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Add two calculated fields in your query like this:
    Code:
    PosAmt:IIF([Amt]>0,[Amt],0)
    NegAmt: IIF([Amt]<0,[Amt],0)
    Now you have two fields/columns, one for positive amounts and one for negative amounts.
    If you want to hide the zeroes on your Report, you can do that with Conditional Formatting.

  3. #3
    robnsd is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2015
    Posts
    9
    Thanks. I used your suggestion for the query. But now I want a report with two separate columns, where each entire record for [Amt] greater than zero appears on one side of the report and the entire record for [Amt] less than zero appears on the other side of the report. Two separate columns.

  4. #4
    JamesDeckert is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262
    In your report, one field is called PosAmt, and the other is called NegAmt. Look at the fields available to put on the report.

  5. #5
    robnsd is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2015
    Posts
    9
    I'm sorry if I am not getting this. Maybe I'm not clear enough. My report (in simplified form) would look like this where there would be two columns side by side, on one side only the records that have positive amounts and on the other only records that have negative amounts.

    Name.......PosAmt Name.......NegAmt

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If the Name value is not supposed to be the same on both sides of one row, like:

    Name Amt Name Amt
    f 5 d -1
    g 4 e -3
    i 7 r -1
    k 2 w -2
    l 6
    q 3

    options I see are:

    1. multi-column (snaking down then right) page setup with group set with an expression IIf([Amt]>=0,"APos","BNeg") then set the group header NewRowOrCol property to AfterSection

    2. two subreports

    3. writing records to temp table
    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.

  7. #7
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Once you have two fields, two columns is easy (the PosAmt in one column and the NegAmt in the other). That is all that different "columns" really are on Reports, they are just different "fields".

    If the issue is that you do not want an alternating type pattern, where if there is a number in the Positive column, the Negative column will show a zero or blank, that you want to "move" everything up in each column to not show any blanks or zeros, then you will need to use one of the options that June provided.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    If you want data to look like:
    Name Pos Neg
    ABC 5 -1
    DEF 4 -3
    GHI 7 -1
    JKL 2 -2
    MNO 6
    PQR 3

    Then maybe need to do a GROUP BY (Totals) aggregate query. Use JoeM's suggested expressions to construct the two fields in query and group the data by name using Sum or Max functions to summarize the two calculated fields to single row for each Name. Or build report using Sorting & Grouping features with aggregate calcs in group header/footer section
    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. Replies: 4
    Last Post: 07-10-2014, 02:24 PM
  2. Comparing positive to negative values.
    By rubberducky in forum Access
    Replies: 1
    Last Post: 01-20-2014, 04:44 PM
  3. Replies: 2
    Last Post: 06-05-2013, 09:37 AM
  4. Replies: 7
    Last Post: 09-16-2011, 01:39 PM
  5. Convert Negative Values to Positive
    By creativefusion in forum Queries
    Replies: 1
    Last Post: 10-21-2009, 02:47 AM

Tags for this Thread

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