Excel Pivot Tables Include Relatively Missing Fields - excel

I have two tables:
TABLE 1
Zone
Proj.
Alpha
22
Gamma
23
TABLE 2
Zone
Real
Kappa
37
Gamma
25
I am pivoting these tables side by side for contrasting the difference between projection and real values. Now, I want both of these pivots to contain the union of Zones found in both the sheets and fill corresponding Sales with something like N.A. or 0, if not found in the respective source.
PIVOT 1
Zone
Proj.
Alpha
22
Gamma
23
Kappa
N.A.
PIVOT 2
Zone
Real
Alpha
N. A
Gamma
25
Kappa
37
I am aware of LOOKUP etc. (or LEFT JOINS using ETL tools) but looking at a "cleaner" and "easier" option.
Use-case: I have two tables—one with annual sales data of about a few thousand sales agents and another with their predictions, as generated last year—but the prediction table lacks rows for 6-7 customers in the second table. So, when I pivot both on the same worksheet, the visual harmony gets disturbed once a missing row is encountered.

Related

excel PowerPivot Auto Calculated Measures & Columns

After looking at a few similarish questions I figured I needed something more specific so asking here. I will start by explaining the situation:
The Setup
I have a Store which sells Cakes, Cookies and Wine. I have the weekly sales data of each product sorta like this:
Product ID
Product Name
Quantity
Value
Week Ending
1
Ginderbread
2
£4
13/01/22
2
Chocolate chip
5
£25
13/01/22
3
Red Wine Bottle
1
£10
13/01/22
4
Sponge Cake
3
£9
13/01/22
Currently every week's data is stored within the same table, with me using a Week filter to show only the week i'm interested in.
Using this Data I created PivotTables that shows the sales of each category, with the ability to drill down to show the specific products. Table looks something like this:
Category
Quantity
Value
Cakes
2
£4
Cookies
7
£29
Wine
1
£10
The issue
I now want to stick in a new calculated column that shows the Value as a %. E.g The total value for the previous table was £43, so Cookies is about 67%. If I drill down, it would show the Chocolate Chip record as 80% and Gingerbread as 20%
I imagine doing this would be easier if each individual week's data was on a different table, but I got a lot of weeks and I also want to do tables showing the sales for over a period of time. Plus I don't know of a way to merge the "value" and "quantity" columns, etc instead of having 1 for each week being shown.
any advice would be appreciated
Create an extra column in the source table (prior to filtering) entitled "perc" calculated as the corresponding value for each row divdied by the total value across all rows (se pic. / eqn. for first row below) --
=E2/$E$6
No calculated fields required - just include perc as the mesaure of interest in your pivot table, with value setting as 'sum':
The reason why this worked is because of the common denominator - which allows one to sum ratios on a 1:1 basis.
Devising a calculated field using the standard 'fields, items & sets' functionality for ordinary pivot tables would not be feasible / possible as far as I am aware. You would need to move into the realm of power pivots and data models - which is not too complicated (readily accesible directly from the field list per below) - however, I see this as unnecessary complication for the task at hand.
Side notes:
Using table names in your functions is sometimes more convenient when entering, albeit may appear tricky at first when reviewing - first eqn above becomes:
=[#Value]/Table1[[#Totals],[Value]]

Different aggregation functions for different dimensions in Excel pivot table

Can I define different aggregation methods for subtotals in different dimension in an Excel pivot table?
The following example shows a result I'm trying to obtain. The metric to aggregate is, let's say, lines of code of a software project. The 2 dimensions in question are Date and Organization. In source data, Organization is broken down into 2 columns, Department and Project, while Date is a single column and Excel makes up the Months/Years summaries automatically when making the ODBC data connection.
A metric such as this one should be aggregated differently along the different dimensions. For the Organization dimension, the subtotal for all projects of the department is the SUM, but in the date dimension, the subtotal for all months of the year is the MAX of any given month (or perhaps AVG, or last etc. but certainly not SUM).
I've tried to define the different aggregation methods in Excel in the field settings, but it always selects one or the other method for both dimensions. Is there a way to do it, preferably using standard Pivot Table mechanisms or at worst a UDF in Excel?
What I would do to tackle this problem is to add both aggregation functions: sum and max , then hide ( or shrink a lot ) those columns you do not want to display.
in the above example I shrink columns B,D,F and I because of they has values that are out of scope for your requirements.
The "Total Max of Loc" displays a value consistent with the function expressed throughout the entire column: that is "the maximum number of lines of code reached by each project in each department; this could lead to misunderstandings when we observe the values of the subtotals and grand total; i.e: The "Grand Total - Total Max of Loc" is not the "Total Max of Sum of Loc": in the example, it shows 18 which represents the absolute maximum value of Loc in a Project in each Department; In the same way the Total Max of Loc for Department 2 is 18 and form Department 1 is 12
When requested a different behavior as expressed in comment to this answer, I think we are entering into the strong customizations space and some solution could be found by writing custom macro and by leveraging the getpivotdata function or, if it can be acceptable for your case, simply by the addition of a new column with the max()formula and possibly hiding the column "Total Max of Loc"

PowerPivot relations

I'm trying to build a Pivot table out of 4 tables that i have loaded in PowerPivot.
the information in the rows of the Pivot is like this:
Region
account
Products
One of the tables has the forecasted values for all 4 quarters for each Region but when i add it as Sum Values it repeats the entire number for each product but i just want the total. Is there a way to fix it without having to change the color of the font to white to hide it?
Without more info can't be sure, but this looks like you have not set up the model to support the Quarterly Forecast Measures in PowerPivot. To get this to work, there needs to be one-to-many relationships between identifying fields in each table.
PowerDax answered based on the assumption that you intended for the Quarterly Forecast to roll up to the region because you phrased you're question to indicate the forecast data is at the regional granularity.
If the forecast data is in one fact table, and the EXT_SELL_PRICE is in another, you will need to set up dimension tables each containing unique lists of the members of each field you are using to slice and dice the report (looks like End User Region, Child Customer, forecast product name). Relate all you're fact tables (tables that contain you're actual data) to these and put the dimension table fields in the Rows area of the pivot table. Then the measures will have some way of understanding how they relate to the rows they are being applied to.
Hope that helps
it would be best for these to be actual calculated fields rather than implicit calculated fields (i.e. dropping the column onto the pivot table). This way you can utilize the isfiltered function to drive what you are looking for.
i.e. if your data is at this granularity:
Region Customer Product Ext_Sell_Price Q1 Q2 Q3
Brazil Acuntia 39XX 17246 743799 672599 748339
Brazil Acuntia 51XX 130918 743799 672599 748339
or you have the sales table and a region forecast table with a relationship to the sales table, you could check to ensure customer/product were not filtered in order to show the forecast:
Q1 Total:=IF( ISFILTERED( Table1[Customer]) || ISFILTERED( Table1[Product]), BLANK(), MIN( Table1[Q1]) )

PivotTable - Filter Row

I am working on creating a pivot table for the data I have. The data looks something like below:
ID Policy_July Policy_June Policy_May Policy_April Label
13 High Med High High High Good
2 Low Low Low Low Low Good
3 Low Low Low Low Low Good
4 High Med High High High Good
5 High Low High High High Good
6 Low Low Low Low Low Bad
7 High Med High High High Bad
8 High Low High High High Bad
I am comparing results from July with other months. Is there a way I can add a filter for row to enable me to change "Policy_June" to "Policy_March"? Basically, instead of having a filter for column, can I have filter for row in pivot table? If so, can you please guide me on how can I do it?
Again, what I am looking for is to have a filter button above the pivot table that would enable me to change "Policy_June" to "Policy_April".
Secondly, is there a way I can have "Grand Total" as a column (like I have at the bottom of pivot table)? I am trying to sum the value of "Bad" and "Good" for "High" and show the result in the column in yellow.
Let me know if you need any additional clarification.
You can normalize your data by giving it a layout similar to this:
ID PolicyMonth Status Label
13 July High Good
13 June Med Good
13 May High Good
...
and create a Pivot with ID in vertical (Row Labels) and Status in horizontal (Column Labels) direction. You then can filter Row and Column Labels for a single (or multiple) values.
Not sure though how you would like to process the crosspoint data (Status, Label) as you only can sum/count/average/min/max by default ... this possibly may require conversion of Low/Med/High into numbers (0,1,2) and an average for the row total.
Edit
Further to your comments I understand you want to analyze a Delta ...
columns A..G contain original data
columns H..L contain a numeric representation according to formula
H5: =IF(B5="High",2,IF(B5="Med",1,0))
cells C1 and C2 contain the month names to be compared ... they are identical to headers in H4..L4; change as you like ... data validation using a list of values and in-cell drop-down is thinkable
column M - big trick - is calculated using INDEX and MATCH functions, i.e.
M4: =INDEX(H5:L5,1,MATCH($C$1,$H$4:$L$4,0))-INDEX(H5:L5,1,MATCH($C$2,$H$4:$L$4,0))
Pivot table is created with Diff as Row Label and count(ID) as data, displaying the ones that stayed flat (0), jumped up or down by 1 or 2 levels ... this of course can be filtered to supress or highlight the ones staying equal.
Result in Diff could be further processed into a DiffText using nested IF's and displayed in pivot rows instead of Diff
in screenshot: 3 ID's stayed unchanged, 3 ID's improved by 1 level, 2 ID's improved by 2 levels
Pivot table can drill down to the ID level to show WHO were the good/bad guys if you add ID to the row labels
Hope this comes closer than my 1st attempt.
open image in new tab to get larger size

Powerpivot: Joining historicals for database and forecast from a calculated linked table in a single pivottable

I noticed a few people have tried to do similar things that I am asking below. I may have a suggestion in my answer as to how I fix it so i'll ask the question first.
I have historical data that I source from a datawarehouse connection and load into Powerpivot:
Date Store Sales NumTransactions Tag
2010-01-01 A 20000 50 Historical
2010-01-01 B 15000 10 Historical
2010-01-01 C 5000 3 Historical
2010-01-01 D 300000 500 Historical
That connection to Powerpivot is a direct connection to the database server.
And from this data, i calculate a forecast, within excel that spits out a table that is then brought into PowerPivot using a linked table.
Date Store Sales NumTransactions Tag
2010-01-02 A 20010 51 Forecast
2010-01-02 B 16000 12 Forecast
2010-01-02 C 6000 5 Forecast
2010-01-02 D 400000 650 Forecast
From this I want to be able to drive a number of pivot tables and charts which show both sets of data together:
Date Store Sales NumTransactions Tag
2010-01-01 A 20000 50 Historical
2010-01-01 B 15000 10 Historical
2010-01-01 C 5000 3 Historical
2010-01-01 D 300000 500 Historical
2010-01-02 A 20010 51 Forecast
2010-01-02 B 16000 12 Forecast
2010-01-02 C 6000 5 Forecast
2010-01-02 D 400000 650 Forecast
How do i make this happen? I cant seem to make a relationship work as there is multiple dates and multiple store records.
I have tried to join the two together at within Powerpivot in Table Properties -> Query Editor:
SELECT [daily].* FROM [daily]
UNION ALL
SELECT [fcst].* from [fcst]
(Where [daily] is the historical data from the datawarehouse and [fcst] is the linked table within the excel workbook that has been linked into powerpivot)
But the problem is that Powerpivot is looking for [fcst] from the Connection that goes back to the datawarehouse where my historicals are coming from.
I can make a work around of driving two pivot tables out of the two data sources and then link them together into one table in excel by directly referencing the cells of the pivot tables (and then drive charts off that). But its messy, and Im sure this can be done. I just cant figure out how.
Does the answer lie in a Set defined by MDX?
Any ideas would be greatly appreciated.
Thanks!
When PowerPivot creates a relationship, it needs one table to have a column with distinct values that you use as a lookup column for another table. I would suggest that you create a date table. You can get one from https://datamarket.azure.com/dataset/1542c52d-d466-4094-a801-9ef8fd7c6485 if you don't have an easy way to create one. Then you can create a relationship from daily to date and from fcst to date. I would also add a calculated column to daily with just a string "Historical" and add a calculated column to fcst for a string "Forecast". Add another linked table with two rows in it: Historical, Forecast. Then create a relationship from daily to this linked table. If you create a flattened PivotTable with all this in place - you can get close to what you're looking for, but you're probably going to have one column for sales for historical and another column for sales for forecast. You can create a measure in one of the tables (doesn't matter which one) to use conditional logic to use the applicable value based on the current tag and just use that in your PivotTable instead. Do the same for the number of transactions.
You can also add a table of month end dates that is not linked to any other tables and use that date as a slicer with Dates equal to or less than the Slicer, select Actuals and Dates greater than the Slicer, use the Forecast. In doing this you avoid picking up a partial month of actuals for an incomplete month. Then add a measure such as...
calculate(sum(historical[sales], filter(historical[date]<=max(monthend[Dates]))) + calculate(sum(forecast[sales], filter(forecast[sales]> max(monthend[Dates])))

Resources