Results 1 to 5 of 5

grouping 2 columns to see totals in pivot chart

Threaded View

  1. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,033

    Re: grouping 2 columns to see totals in pivot chart

    Using Power Query which is called Get and Transform in your version of Excel, here is the Mcode to get the results shown in the attached file

    let
        Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Crash Date", type date}, {"Crash", Int64.Type}, {"On System Flag", type text}, {"Crash Latitude", type number}, {"Crash Longitude", type text}, {"Crash Severity", type text}, {"Highway", type text}, {"Reported Street Name", type text}, {"Reported Road Block Number", type text}, {"Reported Intersecting Street Name", type text}, {"First Harmful Event", type text}, {"Manner of Collision", type text}, {"Object Struck", type text}, {"Weather Condition", type text}, {"Light Condition", type text}, {"Crash Contributing Factor List", type text}, {"CountA", Int64.Type}}),
        #"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"Crash Date", "Crash", "Reported Street Name", "Reported Intersecting Street Name"}),
        #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Removed Other Columns", {"Crash Date", "Crash"}, "Attribute", "Value"),
        #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Other Columns","Reported Street Name","Main",Replacer.ReplaceText,{"Attribute", "Value"}),
        #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","Reported Intersecting Street","Secondary",Replacer.ReplaceText,{"Attribute", "Value"}),
        #"Grouped Rows" = Table.Group(#"Replaced Value1", {"Value", "Attribute"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
        #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Value", Order.Ascending}})
    in
        #"Sorted 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.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to create a pivot table/chart with both daily totals and running totals
    By plasteredric in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-14-2020, 07:23 PM
  2. PIVOT CHART grouping with Date
    By slangille35 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-15-2019, 02:41 PM
  3. Pivot Chart Date Grouping
    By Fenrir1016 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-17-2018, 10:05 AM
  4. Totals and % of Totals under certain columns in Pivot Table
    By adrenom in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 09-13-2016, 02:16 PM
  5. Replies: 1
    Last Post: 07-22-2015, 07:16 AM
  6. [SOLVED] A macro for grouping of same values of several columns and totals
    By novice_excel_2012 in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 06-03-2012, 07:09 AM
  7. Grouping Dates into Monthly Totals - Pivot Table.
    By samprince in forum Excel General
    Replies: 3
    Last Post: 10-11-2006, 09:32 AM

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