Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35

    Calculation

    Hi. I have written the following IIF statement in an Access query. The issue with this is that a couple of my lines have values where a negative value in one of the fields is being divided by a field with no value.

    EAC %: IIf([EAC $]=0,0,[EAC $]/[EAC Revenue])

    So in a couple of my lines, the values are:

    ($730.59) / 0
    ($134.80) / 0



    How can I modify this statement to return a 0 in these instances ?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Try:

    EAC %: IIf([EAC $]=0 OR [EAC Revenue] = 0,0,[EAC $]/[EAC Revenue])
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    Genius ! Thank you !

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Quote Originally Posted by DAWNY2007 View Post
    Genius ! Thank you !
    Thank you for your kind words......if only it were true
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    No, that was a very fast response. I am so grateful for this forum and people like you. Have a wonderful day ! TGIF !

  6. #6
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    Ok, so here is another :-)

    Got the $ working, but with the 0 values, some of my percentages are erroring.

    So, here's my calculation for the $ EAC $: IIf([total revenue (as-billed)]=0 Or [cost total]=0,0,+1*[total revenue (as-billed)]+[cost total])
    So here is my % calculation...and in cases where I have instances where I have 0 dollars, I am getting #Num! values: EAC %: +1*[EAC $]/[Total revenue (as-billed)]

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Why do you have +1* in your formula
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    The original file is in Excel and I am trying to rewrite into Access. In Excel, they are using -1, but when I do in Access, I get different values. They are using in Excel to reverse negative dollar amounts.

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Do you really have a field called [Total revenue (as-billed)]
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  10. #10
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    Yes, it is a valid field. I used same field names from the Excel file.

  11. #11
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Quote Originally Posted by DAWNY2007 View Post
    Yes, it is a valid field. I used same field names from the Excel file.
    It may be valid but IMHO it's a poor choice. You should avoid the use of spaces and special characters.
    Can you post a copy of your db, even if it's just a couple of records and the query to illustrate the problem.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  12. #12
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Quote Originally Posted by DAWNY2007 View Post
    Yes, it is a valid field. I used same field names from the Excel file.
    It may be valid but IMHO it's a poor choice.   You should avoid the use of spaces and special characters.
    Can you post a copy of your db, even if it's just a couple of records and the query to illustrate the problem.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  13. #13
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    Sure...see attached with some dummy data. Thanks !
    Attached Files Attached Files

  14. #14
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Try:
    EAC %: IIf([EAC $]=0 Or [Total revenue (as-billed)]=0,0,[EAC $]/[Total revenue (as-billed)])
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  15. #15
    DAWNY2007 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    35
    Yes ! I will do the same for the As-Sold. You are my star today ! :-)

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help with a calculation
    By Cdray in forum Programming
    Replies: 9
    Last Post: 06-26-2015, 09:37 AM
  2. BMI calculation
    By puush in forum Programming
    Replies: 9
    Last Post: 08-19-2014, 05:05 AM
  3. Calculation Field in table vs Query calculation
    By Leonidsg in forum Database Design
    Replies: 18
    Last Post: 02-28-2013, 09:38 PM
  4. Calculation
    By buienxg in forum Access
    Replies: 1
    Last Post: 11-16-2011, 07:20 AM
  5. value calculation
    By kyle in forum Access
    Replies: 3
    Last Post: 03-06-2011, 12:29 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