+ Reply to Thread
Results 1 to 11 of 11

sort and sum costs by month and by type

  1. #1
    Registered User
    Join Date
    08-17-2020
    Location
    Newquay, England
    MS-Off Ver
    16.21
    Posts
    7

    sort and sum costs by month and by type

    Hello everyone,

    I have 1000+ items expense list across 15 different cost types and all different payment dates. I need to show a monthly sum of the different cost types. I have a feeling that it is an index/match formula but I always end up getting confused with that. I also don't know if it is possible to sum expenses in a month as I have specific dates in the cells. Please find attached a simplified version of the expense list (well, let's hope I can actually attach it).
    I am so grateful for all you geniuses in advance.

    Many thanks in advance
    Attached Files Attached Files
    Last edited by huginori; 01-23-2025 at 07:15 AM. Reason: missing word in heading

  2. #2
    Forum Contributor
    Join Date
    01-07-2025
    Location
    Iran
    MS-Off Ver
    2021
    Posts
    137

    Re: sort and sum costs by month and by type

    you should use the Month & Filter functions for this, so use this formula:

    PHP Code: 
    =IFERROR(SUM(FILTER($C$2:$C$22,($A$2:$A$22=$E2)*(MONTH($B$2:$B$22)=MONTH(F$1)))),""
    And if you want the reports to be longer than a one-year period, you can use the following formula:

    PHP Code: 
    =IFERROR(SUM(FILTER($C$2:$C$23,($A$2:$A$23=$E2)*(MONTH($B$2:$B$23)=MONTH(F$1))*(YEAR($B$2:$B$23)=YEAR(F$1)))),""
    Attached Files Attached Files
    Last edited by MiNd_HuNT3r; 01-23-2025 at 08:39 AM.

  3. #3
    Registered User
    Join Date
    08-17-2020
    Location
    Newquay, England
    MS-Off Ver
    16.21
    Posts
    7

    Re: sort and sum costs by month and by type

    Thank you very much MiNd_HuNT3r!

    This works perfectly with the example I've given. I have tried to apply to my actual sheet but returned blanks only.
    I added an extra sheet to demonstrate what I did (V2)- I had to change the column references, but I don't see what I messed up. (I deleted sensitive info and hidden irrelevant columns)
    The cost headings are copy pasted (originally from a dropdown list in both the source table and the output table) so there should not be a difference.
    I have played around with the date formats to make them the same in both the source table and the output table, but didn't seem to make a difference.

    Could you please look at my sheet and see where I made a mistake? Thank you very much in advance for your help!
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,671

    Re: sort and sum costs by month and by type

    Check out your date fields (column H) where there invalid values.
    Last edited by JohnTopley; 01-23-2025 at 01:51 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Forum Contributor
    Join Date
    01-07-2025
    Location
    Iran
    MS-Off Ver
    2021
    Posts
    137

    Re: sort and sum costs by month and by type

    Your data in column Defrayal Date has problem and I had to change the formula and it worked, but some cells in column Defrayal Date were invalid, so They were not included in the calculations, By the way some cells don't have date. I recognized it for you under the table.

    PHP Code: 
    =IFERROR(SUMIFS($O$2:$O$300,$D$2:$D$300,$S2,$H$2:$H$300,">="&DATE(YEAR(T$1),MONTH(T$1),1),$H$2:$H$300,"<"&DATE(YEAR(T$1),MONTH(T$1)+1,1)),""
    Attached Files Attached Files
    Last edited by MiNd_HuNT3r; 01-24-2025 at 01:35 AM.

  6. #6
    Registered User
    Join Date
    08-17-2020
    Location
    Newquay, England
    MS-Off Ver
    16.21
    Posts
    7

    Re: sort and sum costs by month and by type

    Thank you very much MiNd_HuNT3r!
    Yes, some of the expenses have not been paid yet so they do not need to be added just yet. I have fixes those few entries where I didn't have a valid date format (typos). It works now, I just need to find why my totals don't add up (it's going to be a silly mistake somewhere I made and I don't want to bother you with it).
    Can you tell me what was the problem with the data in "Defrayal date" column? I am curious to learn.

    Thank you very much for you thorough and quick responses!

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,671

    Re: sort and sum costs by month and by type

    Check rows 54,60,66,121

  8. #8
    Forum Contributor
    Join Date
    01-07-2025
    Location
    Iran
    MS-Off Ver
    2021
    Posts
    137

    Re: sort and sum costs by month and by type

    Welcome. I'm glad to hear that.
    The FILTER function can't properly handle date data for month and year comparisons unless all date values are correctly recognized and logical calculations are applied in the FILTER conditions. If there's even one invalid date or a value not recognized as a date within the range $H$2:$H$300, the FILTER function will throw an error. Additionally, the conditional multiplication (*) for combining conditions in FILTER can cause errors in some cases, especially when TRUE/FALSE values are mixed with non-numeric data.

  9. #9
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,268

    Re: sort and sum costs by month and by type

    "F2"
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Copy paste across.


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,669

    Re: sort and sum costs by month and by type

    Why not a pivot table
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  11. #11
    Registered User
    Join Date
    08-17-2020
    Location
    Newquay, England
    MS-Off Ver
    16.21
    Posts
    7

    Re: sort and sum costs by month and by type

    Thank you very much All, especially MiNd_HuNT3r
    I've changed the date format into "long date" and that highlighted where the (to me) less obvious issues were.
    Now it all balances out (sum or source table equals the sum of the output) and it is BEAUTIFUL! Saved me a few days of having to do this manually (as there will be another couple of thousands of rows).

    Thank you very much again for all your brilliant minds!

    Have a great weekend,

    Nora

+ 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. [SOLVED] Can't apportion multi-month costs by month
    By Ochimus in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-13-2020, 01:33 PM
  2. Costs per Month
    By morerockin in forum Excel General
    Replies: 21
    Last Post: 03-09-2015, 08:47 PM
  3. [SOLVED] Sum costs for a month and year using sumifs
    By bberger1985 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-17-2014, 01:08 PM
  4. Develop Macros to Display Costs for Each Month (VBA)
    By Stryker152 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2014, 08:26 PM
  5. Replies: 3
    Last Post: 07-28-2014, 08:57 PM
  6. Combine costs per month
    By kanuvas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2009, 07:03 AM
  7. storage costs that vary in weight each month
    By repke in forum Excel General
    Replies: 4
    Last Post: 05-08-2008, 09:00 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