+ Reply to Thread
Results 1 to 7 of 7

Sum Output per Year

Hybrid View

  1. #1
    Registered User
    Join Date
    11-14-2023
    Location
    Zurich
    MS-Off Ver
    365
    Posts
    2

    Sum Output per Year

    Dear all

    How would calculate the total Quantity for year 2025 if the data set has to be arranged like this:

    Excel 1.PNG

    Many thanks for your ideas and support!
    Kind regards

    Excel Example.xlsx
    Last edited by silunietli; 11-14-2023 at 01:09 PM.

  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
    48,333

    Re: Sum Output per Year

    You could use FILTER or SUMPRODUCT to sum values where the header contains "Quantity". Assuming the " pcs" is text rather than a Custom Format, you could use SUBSTITUTE to remove it. Your picture only shows months in 2025. Are there other years?


    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.
    Last edited by TMS; 11-14-2023 at 02:11 PM.
    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
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,719

    Re: Sum Output per Year

    It would be easier to do your analysis if you normalize your data. That would allow you to Pivot your data

    A better layout would be

    Column A. Date
    Column B Quantity. Avoid the use of the term pcs. and keep it to numbers only. Once you put the term pcs in the cell it changes the data to Text. Put that term in the header, ie. "Quantity PCS"
    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

  4. #4
    Registered User
    Join Date
    11-14-2023
    Location
    Zurich
    MS-Off Ver
    365
    Posts
    2

    Re: Sum Output per Year

    Thank you for your comments. I just attached the excel file. I need a formula that gives me the total quantity for 2022 / 2023 / 2024 / 2024. Unfortunately the file structure is given and must not change. All the values are formatted numbers

  5. #5
    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,830

    Re: Sum Output per Year

    in M3

    Formula: copy to clipboard
    =SUMPRODUCT((YEAR($A3:$K3)=M$2)*(SUBSTITUTE($B3:$L3,"pcs","")))


    copy across and down

    For All rows

    Formula: copy to clipboard
    =SUMPRODUCT((YEAR($A4:$K9)=M$2)*(SUBSTITUTE($B4:$L9,"pcs","")))
    Attached Files Attached Files
    Last edited by JohnTopley; 11-14-2023 at 01:35 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

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

    Re: Sum Output per Year

    With Power Query

    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {}, "Attribute", "Value"),
        #"Added Custom" = Table.AddColumn(#"Unpivoted Columns", "Quantity", each if Text.Contains([Attribute],"Quantity") then [Value] else null),
        #"Filled Up" = Table.FillUp(#"Added Custom",{"Quantity"}),
        #"Filtered Rows" = Table.SelectRows(#"Filled Up", each not Text.StartsWith([Attribute], "Quantity")),
        #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"Value", type date}}),
        #"Inserted Year" = Table.AddColumn(#"Changed Type", "Year", each Date.Year([Value]), Int64.Type),
        #"Grouped Rows" = Table.Group(#"Inserted Year", {"Year"}, {{"Total Quantity", each List.Sum([Quantity]), type number}})
    in
        #"Grouped Rows"
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.

    Excel 2016 (Windows) 64 bit
    Q
    R
    1
    Year Total Quantity
    2
    2022
    36
    3
    2023
    470
    4
    2024
    73
    5
    2025
    365
    6
    2026
    70
    Sheet: Sheet1
    Attached Files Attached Files

  7. #7
    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
    48,333

    Re: Sum Output per Year

    One option with FILTER

    Formula: copy to clipboard
    =IFERROR(SUM(FILTER($B3:$L3,YEAR($A3:$K3)=M$2),0),"")
    copied across and down.

+ 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] if values between x and y date each year output yes
    By deweyirl in forum Excel General
    Replies: 23
    Last Post: 10-13-2023, 05:05 AM
  2. [SOLVED] Pivot table remove the year row from the output
    By mcva in forum Excel General
    Replies: 15
    Last Post: 06-17-2022, 02:07 PM
  3. Replies: 8
    Last Post: 07-23-2020, 04:16 AM
  4. Does Excel Formula Exist to Output Same Period Last Year?
    By zsaddique in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-03-2018, 11:55 AM
  5. [SOLVED] Getting wrong output by year formula
    By mso3 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-19-2015, 07:26 AM
  6. Replies: 1
    Last Post: 04-22-2015, 08:08 AM
  7. [SOLVED] Function to Output Current Month and Year
    By cg0789 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-13-2012, 01:46 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