+ Reply to Thread
Results 1 to 7 of 7

Return value or sum based on multiple sections of database file

  1. #1
    Registered User
    Join Date
    01-21-2019
    Location
    Macon, MO
    MS-Off Ver
    Microsoft Excel for Office 365 Pro Plus
    Posts
    3

    Exclamation Return value or sum based on multiple sections of database file

    Hi,

    I have built a profit and loss statement into a databse layout in excel: In each row of data, Column A is business unit - Column B is Month - Column C is expense type A amount, Column D is expense type B amount, etc.

    For example, A2 would be "Accounting" (department), B2 would be "January" (month), C2 would be $400 (Amount in Office Supplies - 6500) and D2 would be $25 (Amount in IT Harddware - 6200). There is a row per department, per month on the "detail" tab of my worksheet (database), so if Accounting had expenses for February, they'd be on row 3 in this example.

    I need the profit and loss (traditional format, that has a column for the expense category number, ex above 6500) to return the value of the specific business unit's expense in a given month. For example, if I was building a profit and loss statement for Accounting for January's column, it should return $400 on the row for Office Supplies and $25 for IT Hardware.

    so far, I've been able to query total expense, just can't get it narrowed down by department as well as month - below is the formula for the total expenses - detail!K represents the column for month on the database tab, C2 here represents month on the P&L tab, B24 represents the cell on the P&L tab where the expense category number is stored, and row 1 on the detail tab is where the expense category is stored on the database tab.
    =IFERROR((SUMIF(detail!$K$2:$K$2000, C$2, INDEX(detail!$U$3:$BG$2000, 0, MATCH($B24, detail!$U$1:$BG$1, 0)))),0)

    Any help from you in tremendously appreciated!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,411

    Re: Return value or sum based on multiple sections of database file

    Maybe look at SUMIFS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    01-21-2019
    Location
    Macon, MO
    MS-Off Ver
    Microsoft Excel for Office 365 Pro Plus
    Posts
    3

    Re: Return value or sum based on multiple sections of database file

    Thank you TMS, I did look into Sumifs and tried this variation: =IFERROR((SUMIFS(INDEX(detail!$U$3:$BG$2000, 0, MATCH(Build!$B22, detail!$U$1:$BG$1, 0)), detail!$K$2:$K$2000, C$2)),0)

    (all I did was switch to sumifs and used the one criteria of month), and the field that previously had the correct dollar amount in the field now says $0, so it's not working correctly.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,411

    Re: Return value or sum based on multiple sections of database file

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  5. #5
    Registered User
    Join Date
    01-21-2019
    Location
    Macon, MO
    MS-Off Ver
    Microsoft Excel for Office 365 Pro Plus
    Posts
    3

    Re: Return value or sum based on multiple sections of database file

    I found the error while working to get a sample workbook put together.

    For anyone else using a similar setup, the root of the problem seemed to be that the array areas weren't equal. For example, my data was row 3 to row 2000, but my months rows was row 2 to row 2000.

    Correct, working formula is =IFERROR((SUMIFS(INDEX(detail!$U$3:$BG$2000, 0, MATCH($B22, detail!$U$1:$BG$1, 0)), detail!$K$3:$K$2000, C$2, detail!$D$3:$D$2000, $A$1)),0).

    Thank you for your time!!

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,411

    Re: Return value or sum based on multiple sections of database file

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Return value or sum based on multiple sections of database file

    Quote Originally Posted by chelseamilleronshore View Post
    I found the error while working to get a sample workbook put together.

    For anyone else using a similar setup, the root of the problem seemed to be that the array areas weren't equal. For example, my data was row 3 to row 2000, but my months rows was row 2 to row 2000. ...
    Good catch. Thank you for letting us know.
    Dave

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 10-25-2018, 04:08 PM
  2. Formula to search database and return data based on alphabet (NEED HELP)
    By galbatrox9 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-19-2016, 02:58 PM
  3. Replies: 11
    Last Post: 08-31-2016, 12:00 PM
  4. Replies: 1
    Last Post: 02-19-2015, 02:40 PM
  5. How to return multiple values from a large database
    By kdelgreco2014 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-10-2014, 11:39 AM
  6. Adding variable percentages to sections of a large database.
    By JohnDoh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2013, 06:24 PM
  7. Replies: 4
    Last Post: 06-09-2012, 03:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1