Results 1 to 5 of 5
  1. #1
    sunitarobert is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2015
    Posts
    3

    Angry sumif for same field range & criteria

    Hi All,

    Need your expertee for below query..

    I have query which is fetching data from SAP Table and has expression Inv_No: IIf([Type]<>"KY",[Reference],[Assign]). It means if the KY Document is it should take the Invoice Reference from Assign Field else from Reference field. which is working fine..



    Now I have another requirement i.e., sum if based on expression "Inv_No: IIf([Type]<>"KY",[Reference],[Assign])" In field 'Amount in DC' have negative & positive and I want have sumif in same query.


    eg. in Query field Invoice No. Amount in DC "in new field"
    1234 5000 0
    1234 -5000 0

    In excel it is pretty easy, but I want to do this in access because of huge data.. sample file attached.. kindly help
    Attached Files Attached Files

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    it sounds like you need a groupby query and

    summed:sum(IIf([Type]<>"KY",[amount in dc],0)

    but not clear if this is really what you mean.

    you need to clarify what you mean by 'want have sumif in same query.'

    suggest provide some example data and the result you want to achieve

  3. #3
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,928
    ah - think I've worked out what you mean

    Code:
    select inv_no, [amount in dc], (select sum([amount in dc]) from sap as s where inv_no=sap.inv_no) as newfield
    from sap

  4. #4
    sunitarobert is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2015
    Posts
    3
    Thank you so much.. it works superb.. but Inv_no is not field in query. It is expression "Inv_No: IIf([Type]<>"KY",[Reference],[Assign])" fetching data from SAP table. Above solution works if I create an another query. Is it possible to consider IIf([Type]<>"KY",[Reference],[Assign]) in same query instead of Inv_No.

  5. #5
    sunitarobert is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2015
    Posts
    3
    Hi Ajax,

    Found Answer.. thanks a lot for your help.. Contra: (select sum([amount in dc]) from sap as s where IIf([Type]<>"KY",[Reference],[Assign])=IIf(sap.[Type]<>"KY",sap.[Reference],sap.[Assign]))s where IIf([Type]<>"KY",[Reference],[Assign])=IIf(sap.[Type]<>"KY",sap.[Reference],sap.[Assign]))

    Rgds,

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

Similar Threads

  1. Replies: 18
    Last Post: 03-26-2015, 07:26 AM
  2. Replies: 9
    Last Post: 02-21-2014, 06:02 PM
  3. Forms and Date Range Criteria
    By RoundTrip in forum Access
    Replies: 9
    Last Post: 02-12-2014, 10:02 PM
  4. Date Range Criteria help
    By jsubby3 in forum Access
    Replies: 7
    Last Post: 12-03-2012, 03:14 PM
  5. Criteria to show date range
    By Douglasrac in forum Queries
    Replies: 2
    Last Post: 03-24-2011, 03:58 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