Results 1 to 5 of 5
  1. #1
    suverman is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    15

    Net of 2 fields...

    Hello, I have a table like

    Code A B


    3456 40 20
    4587 10 50
    5435 100 20
    3456 50 100

    By running a query I should get...

    Code A B
    3456 0 30
    4587 0 40
    5435 80 0

    Basically the net to be shown wherever it is positive.
    Thank you.

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    how is it that the first line is 30? in one line you subtract A from B, in the next line you subtact B from A.

    confusing math.....

  3. #3
    suverman is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    15
    Quote Originally Posted by NTC View Post
    how is it that the first line is 30? in one line you subtract A from B, in the next line you subtact B from A.

    confusing math.....
    Ah, actually the first line is the consolidation of the first and the last record, whcih has the same code. The over-all effect is a 30 in B.

  4. #4
    suverman is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    15
    Its more like

    In column A
    if(A>B, A-B, 0)

    In column B
    if(B>A, B-A,0)

  5. #5
    Rhino373 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    65
    I can't see how to do this without to queries. You can do it a couple ways but an example would be the first would be a totals query grouping by Code and sum of the other two. The second query would be based off the first using the exact IF statements you made. so column A would be like "ColumnA: IIF(A>B, A-B, 0)" and B of course would be the other with the Code field as well.

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

Similar Threads

  1. Combine two fields, Null fields involved
    By yes sir in forum Access
    Replies: 9
    Last Post: 10-03-2010, 09:20 AM
  2. Replies: 5
    Last Post: 03-20-2010, 08:30 AM
  3. Replies: 3
    Last Post: 08-10-2009, 08:33 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