Results 1 to 3 of 3
  1. #1
    glmleilei is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Apr 2015
    Posts
    4

    PLS Help!! Sumif formula in MS Access

    I've been searching the answer for the whole day, and wont be able to find my answer. Thanks for your help in advance! I'll get straght into it.


    My Dataset:
    ColunmA ColunmB Value
    a b 1
    b d 2
    a q 3
    c a 5
    b e 2
    d e 10
    f q 1
    q m 8
    . . .
    . . .
    . . .


    In Excel, I would do sumif( ColunmB,a2,Value), which gives me a result:


    ColunmA ColunmB Value Result
    a b 1 15
    b d 2 2


    a q 3 15
    c a 5 8
    b e 2 2
    d a 10 2
    f b 1 0
    q c 8 0
    . . . .
    . . . .
    . . . .


    So based on each string in ColunmA, it would search all ColunmB and return an aggregated value.
    How can i get the same result by Access/SQL query?


    Regards,


    Michael

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    This is not simple.

    Search forum on keyword SumIf.

    Here is one: https://www.accessforums.net/access/...-if-51205.html

    Consider:

    SELECT Table1.A, Table1.B, Query1.B, Query1.SumOfValue
    FROM (SELECT Table1.B, Sum(Table1.Value) AS SumOfValue
    FROM Table1
    GROUP BY Table1.B) AS Query1 RIGHT JOIN Table1 ON Query1.B = Table1.A;
    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.

  3. #3
    glmleilei is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Apr 2015
    Posts
    4
    Answer:

    SELECT *, (SELECT Sum(Value) FROM myDataset AS T WHERE ColumnB=myDataset.ColumnA) AS Result
    FROM myDataset

    __________________
    CJ_London

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

Similar Threads

  1. Replies: 41
    Last Post: 05-29-2015, 02:58 PM
  2. SumIF in access
    By sharkantipav in forum Programming
    Replies: 1
    Last Post: 03-19-2014, 12:48 PM
  3. sumif in Access
    By JGrots in forum Queries
    Replies: 12
    Last Post: 01-17-2013, 02:37 PM
  4. Complex "sumif" style formula
    By groonpooch in forum Queries
    Replies: 3
    Last Post: 12-16-2011, 07:05 PM
  5. Sumif in an Access report
    By tigers in forum Reports
    Replies: 0
    Last Post: 03-15-2007, 12:19 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