+ Reply to Thread
Results 1 to 7 of 7

Sum Output per Year

Hybrid View

  1. #1
    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
    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

+ 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