+ Reply to Thread
Results 1 to 9 of 9

PivotTable - Adding New Columns

  1. #1
    Registered User
    Join Date
    11-10-2012
    Location
    Kuala Lumpur
    MS-Off Ver
    Excel 2010 (Home), Excel 2021 (Office)
    Posts
    18

    PivotTable - Adding New Columns

    Dear Experts

    Need help in adding 3 new columns (columns Q, R & S) into an existing PivotTable below:

    ExcelForum PivotTable.png

    Thank you in advance.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,570

    Re: PivotTable - Adding New Columns

    Perhaps this will be a starting point that another contributor can improve upon.
    I could not get the desired result using the data model and Power Pivot, however Power Query produces the result modeled on the SalesData sheet.
    Here is the M-Code:
    Please Login or Register  to view this content.
    Note that the Stock Balance will need to be typed into the column in the Power Query editor window as opposed to the StockBalance table. (Perhaps someone will know a way to merge the SalesData and StockBalance tables).
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  3. #3
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,570

    Re: PivotTable - Adding New Columns

    Here is a better proposal although I imagine it can be streamlined:
    1. Use the following to transform and make a connection to the SalesData table:
    Please Login or Register  to view this content.
    2. Use the following to make a connection to the StockBalance table:
    Please Login or Register  to view this content.
    3. Use the following to merge the two connection only tables and add the Months Holding column:
    Please Login or Register  to view this content.
    Let us know if you have any questions.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    07-29-2023
    Location
    Singapore
    MS-Off Ver
    M365
    Posts
    1

    Re: PivotTable - Adding New Columns

    Here's another option, also using Power Query. I tried to make it more dynamic so that the average would recompute when there is new data added for subsequent months (eg Jul, Aug etc). My proposed solution does involve quite a number of steps, so perhaps another contributor would have better ideas on how to make this more efficient. Steps I took as follows:

    1. Load Sales table and stock balance table into Power query
    2. Compute Average sales separate by taking total sales of each product divided by count of number of months with data for each product. Current count is 6, but should automatically change to 7 when July data gets added in.
    3. Compute Stock holding month.
    4. Append sales data, average sales, stock balance, and stock holding month into 1 master table.
    5. Create pivot table based on the master table in step 4.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-10-2012
    Location
    Kuala Lumpur
    MS-Off Ver
    Excel 2010 (Home), Excel 2021 (Office)
    Posts
    18

    Re: PivotTable - Adding New Columns

    Thank you JeteMc for your PQ. It works! But possible not to hard-code the periods in the "Inserted Average" step and also to cater to expanding data.. July month data will be added and to find the last 6 months average (Feb-Jul 2023). Thank you.

  6. #6
    Registered User
    Join Date
    11-10-2012
    Location
    Kuala Lumpur
    MS-Off Ver
    Excel 2010 (Home), Excel 2021 (Office)
    Posts
    18

    Re: PivotTable - Adding New Columns

    Thank you Rows&Columns for your solution. The database is huge with 5 years of sales data (and expanding) with about 3,000 products. The file will become too huge with the added Power query sheet.

  7. #7
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,570

    Re: PivotTable - Adding New Columns

    I feel that Row&Columns solution can be modified to work with your data.
    In the attached file the data that will be used in the production of pivot table (DataModelData) is placed in the data model.
    Let us know if you have any questions.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    11-10-2012
    Location
    Kuala Lumpur
    MS-Off Ver
    Excel 2010 (Home), Excel 2021 (Office)
    Posts
    18

    Re: PivotTable - Adding New Columns

    Thanks JeteMc!

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,570

    Re: PivotTable - Adding New Columns

    You're Welcome. Thank You for the feedback and for marking the thread as 'Solved'. I hope that you have a blessed day.

+ 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. PivotTable keeps adding additional columns on macro run
    By donvang in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-06-2017, 08:48 PM
  2. Adding data to pivottable from another sheet
    By gandreso in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-29-2016, 09:50 AM
  3. PivotTable Field List: Adding Columns
    By michaelweaver4 in forum Excel General
    Replies: 1
    Last Post: 03-15-2011, 10:15 PM
  4. Adding formula to PivotTable
    By WLMPilot in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-07-2006, 08:55 AM
  5. Adding PivotTable to AxSpreadsheet
    By Maggie in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2006, 04:55 PM
  6. [SOLVED] PivotTable -adding more than one function
    By Connie in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-11-2006, 03:00 AM
  7. [SOLVED] Pivottable:adding grand totals
    By [email protected] in forum Excel General
    Replies: 3
    Last Post: 12-06-2005, 06:10 PM

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