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.
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.
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: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).Please Login or Register to view this content.
Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.
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: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.Please Login or Register to view this content.
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.
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.
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.
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.
Thanks JeteMc!
You're Welcome. Thank You for the feedback and for marking the thread as 'Solved'. I hope that you have a blessed day.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks