Results 1 to 7 of 7
  1. #1
    jirakst is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    4

    IIF statement + some math

    Hello,



    what is wrong with this formula: Profit: IIf([Side]="Short";[Exit]-[Entry];[Exit]-[Entry]) ? It returns quite weird number and I can't figure out why.
    Thanks!

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    First, your formula doesn't seem to make much sense. You seem to be telling it to return exactly the same thing if you condition is True or False:
    [Exit]-[Entry]
    In that case, why even bother checking if you are going to return the same formula either way?

    Please provide an example of of what the values or [Exit] and [Entry] are, and what is being returned.

  3. #3
    jirakst is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    4
    Sorry, it should be as follows: IIf([Side]="Short";[Exit]-[Entry]*(-1);[Exit]-[Entry]). I forget to copy the (-1).

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    [Exit]-[Entry]*(-1)
    can simply be replaced with:
    [Entry]-[Exit]

    If still having issues, please lay out an actual example that is not working for you.
    That is, let us know the values for [Entry] and [Exit] and let us know what result you are seeing.

  5. #5
    jirakst is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    4
    It already works. But I'd like to use comma separated number, e.g. Entry=42,225, Exit=45. Is there any way, how to do that?

  6. #6
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    comma separate format should be able to be achieved by definition the type number in the format of the field

  7. #7
    jirakst is offline Novice
    Windows 8 Access 2013
    Join Date
    Sep 2015
    Posts
    4
    I've got it. Thank you very much.

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

Similar Threads

  1. Form Math
    By PSpingola in forum Forms
    Replies: 3
    Last Post: 03-28-2011, 09:29 PM
  2. bad math again
    By newtoAccess in forum Access
    Replies: 1
    Last Post: 12-03-2010, 12:19 AM
  3. Math problem
    By newtoAccess in forum Queries
    Replies: 3
    Last Post: 12-01-2010, 10:34 AM
  4. Simple math
    By Lee in forum Programming
    Replies: 2
    Last Post: 07-27-2010, 04:53 PM
  5. Math problem
    By kbrodrick in forum Programming
    Replies: 3
    Last Post: 05-06-2009, 08:56 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