Results 1 to 7 of 7
  1. #1
    azgaman is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2011
    Location
    Accra
    Posts
    8

    I need help on this multiple condition calculation

    I need help on this:

    I am trying to calculate the arrears for the following:

    Click image for larger version. 

Name:	Untitled.png 
Views:	21 
Size:	3.6 KB 
ID:	13063

    Whilst cost is fixed, I want to be able to get arrears only when Due is ticked(yes).


    As in the case of the image, only Jan, Feb and Mar arrears must be calculated because Due is ticked.
    Thank you.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    iif([DueJan] = -1, [Jan], 0) + iif([DueFeb] = -1, [Feb], 0) + iif([DueMar] = -1, [Mar], 0) + ... etc until you have all months accounted for.

  3. #3
    azgaman is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2011
    Location
    Accra
    Posts
    8
    Thank you, rpeare, for the reply. I learnt that iif functions are nested up to 7 times. Could there be another way for 12 months?
    All the same, as there is no harm in trying I'll get my hands dirty with this one. Thanks again.

  4. #4
    azgaman is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2011
    Location
    Accra
    Posts
    8
    rpeare, upon second look at the formula it is not nested. Each iif is standing on its own. It should work. Thank you very much. I'll get back after using it.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Here is an alternative to rpeare's formula. The end result is the same, just without the IIF() function...
    Code:
    (Abs([DueJan]) * [Jan]) + (Abs([DueFeb]) * [Feb]) + (Abs([DueMar]) * [Mar]) + ... + (Abs([DueDec]) * [Dec])

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    P.S. nested iifs aren't limited to 7, I've had more than that before. It really depends on the length of the statement as to how many nested iifs you can have (I believe I've had up to around 15 before but had to make the field names very short to handle it)

  7. #7
    azgaman is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jul 2011
    Location
    Accra
    Posts
    8
    Thank you for the help. The IIF function worked good. I had to make slight changes to suit my need. I will also try the abs function to see how it also works. I appreciate your help. Thanks once more.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-09-2013, 08:03 PM
  2. Replies: 2
    Last Post: 04-04-2012, 03:52 AM
  3. DLookup with multiple field condition
    By agent- in forum Programming
    Replies: 4
    Last Post: 10-15-2011, 05:17 PM
  4. Printing multiple reports at once based on condition
    By justinwright in forum Reports
    Replies: 24
    Last Post: 04-13-2011, 01:40 PM
  5. Replies: 5
    Last Post: 06-19-2010, 07:55 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