Results 1 to 8 of 8
  1. #1
    vicatucd is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    3

    Converting Excel formula to MS Access calculated queries

    Hello,

    I am having trouble converting Excel formulas to MS Access.

    Excel Formula:


    =COUNTIFS(CY807,">"&CW807, CY807,">3")+COUNTIFS(CY807,"="&CW807,CY807,">7")

    My attempt in MS Access:
    MetSSA: Count((IIf([PostSSA]>[PreSSA] And [PostSSA]>3,1,0) Or IIf([PostSSA]=[PreSSA] And [PostSSA]>7,1,0)))

    Any help is much appreciated!

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Can you explain in words what you are trying to do? Are you running this in a Query? Are those fields all numeric datatype? What is the above Access part returning when you run it? What should it return?

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Maybe
    Code:
    MetSSA: Count(IIf([PostSSA]>[PreSSA] And [PostSSA]>3,1,0)) + Count(IIf([PostSSA]=[PreSSA] And [PostSSA]>7,1,0))

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Maybe:

    MetSSA: IIf([PostSSA]>[PreSSA] And [PostSSA]>3 Or [PostSSA]=[PreSSA] And [PostSSA]>7,1,0)

    or

    SELECT Count(IIf([PostSSA]>[PreSSA] And [PostSSA]>3 Or [PostSSA]=[PreSSA] And [PostSSA]>7,1,0)) AS MetSSA
    FROM tblSSA;

  5. #5
    vicatucd is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    3
    The values are numeric and it is being run as a calculated field in a query.

    I had already attempted:
    MetSSA: IIf([PostSSA]>[PreSSA] And [PostSSA]>3 Or [PostSSA]=[PreSSA] And [PostSSA]>7,1,0)

    but I get errors

    Any other thoughts?

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Access doesn't like And's and Or's mixed together, you need to put brackets around them. (A>B AND B>3) OR (B=C AND B>7) - if that is how you want it.

  7. #7
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    What errors?

  8. #8
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    This worked for me in a query. If you want to do a count take off the first 2 fields and do a Totals "count" for that last field.

    Click image for larger version. 

Name:	tblSSA.png 
Views:	9 
Size:	14.8 KB 
ID:	27426

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

Similar Threads

  1. Replies: 5
    Last Post: 09-09-2016, 08:38 PM
  2. Converting Formula from Excel to Access
    By lansreef in forum Queries
    Replies: 3
    Last Post: 05-26-2016, 01:42 PM
  3. Converting Excel Formula to Access Query Format
    By Guy Winfield in forum Queries
    Replies: 2
    Last Post: 05-11-2015, 06:21 AM
  4. Replies: 7
    Last Post: 11-06-2014, 10:55 AM
  5. Converting this formula to an access database
    By prabha_friend in forum Queries
    Replies: 1
    Last Post: 07-23-2014, 10:11 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