Results 1 to 4 of 4
  1. #1
    ALewis06 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2015
    Posts
    5

    Question Convert Long Excel Formula into Access Expression

    I have the following formula from Excel 2007 and I need to convert it into Access 2007 (yes I know--it kills me that the company I work for is still on 2007!). Please no VBA script--I'm just not there yet. Thanks



    =IF(MONTH(Period0)=1,W2,IF(MONTH(Period0)=2,SUM(W2 :X2),IF(MONTH(Period0)=3,SUM(W2:Y2),IF(MONTH(Perio d0)=4,SUM(W2:Z2),IF(MONTH(Period0)=5,SUM(W2:AA2),I F(MONTH(Period0)=6,SUM(W2:AB2),IF(MONTH(Period0)=7 ,SUM(W2:AC2),IF(MONTH(Period0)=8,SUM(W2:AD2),IF(MO NTH(Period0)=9,SUM(W2:AE2),IF(MONTH(Period0)=10,SU M(W2:AF2),IF(MONTH(Period0)=11,SUM(W2:AG2),SUM(W2: AH2))))))))))))

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    We would need to know your data structure, and if it mimics Excel with monthly values in fields, you've violated normalization rules:

    Fundamentals of Relational Database Design -- r937.com
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    if your table is constructed something like

    myTable
    ...
    Period integer
    Sales currency
    ...
    ...

    Period...Sales
    1..........1000
    2..........2500
    3..........1500
    ...
    ...

    then you would use what is called a running sum query which would be something like

    SELECT PERIOD, (SELECT SUM(Sales) FROM myTable AS T WHERE Period<=myTable.Period) AS CumulativeSales
    FROM myTable
    ORDER BY Period

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Looks like non-normalized to me. This will cause you lots of headaches. The expression will likely be too long and will need custom VBA function.

    Either normalize your tables or manipulate them to emulate normalized structure. A UNION query could rearrange the data to a normalized structure that could then be used as the datasource for subsequent queries as suggested by Ajax.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 19
    Last Post: 07-13-2015, 10:15 AM
  2. Replies: 41
    Last Post: 05-29-2015, 02:58 PM
  3. How to use this formula from Excel in Access?
    By jset818 in forum Queries
    Replies: 11
    Last Post: 10-16-2014, 03:32 PM
  4. Using an Excel Formula in Access
    By BEI77 in forum Access
    Replies: 6
    Last Post: 05-08-2014, 05:08 PM
  5. Replies: 5
    Last Post: 12-14-2011, 08:24 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