How to extend data source for pivot table? - excel

I'm synchronizing data with an external database and the result is delivered to me on a sheet called All Items. Setting up a pivot table is easy. However, on the horizontal axis I need to display a custom value, computed from one of the columns in the externally linked data set.
When I go to Analyze -> Change Data Source, I can see that the currently regarded data area is called 'All Items'!Query. I'd like to extend it by a column or two, so that my pivot table can display these values as well.
So, instead of 'All Items'!Query as the data source I'd like to have 'All Items'!Query and the next two columns too. I have no idea how to approach it nor what to try. Suggestions would be warmly appreciated.
I tried to define my own area called 'All Items'!Query_and_stuff but the number of records retrieved during synchronization varies, so my extension needs to take that into the account. No idea how.

Define
'All Items'!Query_and_stuff = offset('All Items'!Query, 0,0 ROWS('All Items'!Query),COLUMNS('All Items'!Query)+2)

Related

Add text in front of grouped values in pivot tables

I'm trying to create an Excel Pivottable that grabs data from an Access Query and then shows the values grouped by what I want. That part works fine enough, what I would like to know is if it is possible to add text infront of grouped values in a way that is smart? The purpose is to just be able to change which Access database it should grab data from and have a standardised view where no manual changes have to be made.
What I currently have:
What I would to have:
As far as I can see I can add it manually, but there might be new cases of Øxxx types.
I would add reference table with columns sufficient to join to your view and then "prefix text" column that would be appended in front of the existing (quantity in english?) column. Or you could add it to the pivot. This method let's you add/delete rows from the reference table as needed.
If you cannot alter the access side for some reason, then another way is select all the raw data to a sheet and then use VLOOKUP or some other formula to add the prefix. And then pivot this data sheet.

Calculated Field

I am trying to create a simple pivot table which will tell me how many community residents reported a particular problem, and what percentage of them reported each problem type. I have a data set with name, and then columns for each type of problem. Here's an small sample of the data set:
I have created a pivot table which sums each of these columns and also provides me the total number of people who reported any type of problem at all. Here's what I have:
I want to add a second column to this pivot table that gives the percent of times each problem type was reported. Sounds simple, but because of the structure of the original data set, I can't figure out how to do it. I can set up formulas outside of the Pivot Table which reference the table, but in doing so I forfeit the ability to graph the percentages on a pivot chart. Any ideas how to create a calculated field for this pivot table?
Just to be clear, what I want is something like this, except all contained in the structure of the pivot table:
Edit: I've changed the example of the data set. Here's an explanation of the pivot table. The values under the "# Reporting Issue" column are counts of all the 1's under each corresponding column in the data set. This meant that I had to add each row to the pivot table independently, as you can see here:
I'm open to the idea that I need to change the formatting of the data set, but I'm not sure of the best way to do it. This was set up initially because it allowed for easy compilation into a data table, but Pivot Tables seem to be a different story.
Hopefully this edit clarifies things.
You need to unpivot your data so that you turn it into a Flat File...something that the PivotTable can consume properly.
The easiest way is to use something called PowerQuery, which is baked in to Excel 2016 but available as a free addin from Microsoft for any other versions. Google PowerQuery Unpivot and you will turn up hundreds of tutorials, such as this one from my good pal Chandoo . PowerQuery looks slightly daunting at first to a first time user, but it is freakin easy once you get your head around how to use it. PQ is by far the best addition to Excel in years. PowerPivot being a close second.
If you can't install PowerQuery, then you can use your current data structure to make a 'staging pivot', and then drag the Values label that will appear in the Columns area to the bottom of the ROWS pane, like in this excerpt from a book I'm writing:
Note that my Year categories are equivalent to your Issues categories.
That will emulate the flat file layout you’re after. All you need to do then is turn this intermediate PivotTable back into a normal range, change that Values heading to Issue, and add a Count heading and you’ve got the flat file you need to build a useable PivotTable.
You can also use VBA. Google Unpivot VBA and turn up hundreds of results, including this blazingly fast code I posted some time back. (Look for the code under the —Update 26 November 2013— heading.)
You can also use the DoubleClick extraction trick.

Custom row labels in PivotTable

I have an excel spreadsheet full of customer data including a few single letter categorical variables.
For example: property type can be (I for investment, O for owner occupier, or R for renter). Is it possible to replace the single letter with a descriptive title in the rows on a PivotTable? I do not have the descriptive names anywhere in my spreadsheet and I would prefer not to add them.
you can give nicknames to the fields that you are checking which populate the pivot table.
If you go the pivot table data and right click you can change the value field settings to give a custom name to a row/series but I do not know about individual data points.
path: pivot table data => right click => select Field Settings => edit custom name.
It does not look like it modifies the raw data (before pivot table).
It adds the name to the chart as well. So make sure your chart looks okay.
to my knowledge this is the best tool for you to mess around with.
Hopefully this answers your question.
coming from experimenting on excel 2013.

How do you group an Excel PivotChart by a column not selected in category?

Does anyone know if its possible to select one column in an Excel PivotChart (i.e. Name in my example) but sum the values by ID without displaying the ID column in the chart?
In the example below, we have two Johns. I want to view both of them in the chart like in chart two, but I don't want to display their ID fields in the chart.
[EDIT]
Real case scenario is that I need to filter on top 10 file views by file name. And if we have a bunch of files named image1.jpg (because people don't properly name their files), we end up bucketing them all together and it looks like image1.jpg has way more views than it actually has; causing the chart to be skewed. I know it might be confusing to have two same data labels, but oh well. :) The user will just have to drill into one to see other details.
I did find a clean way of doing this using hierarchies in PowerPivot, but with a large dataset the performance is horrible.
Create a hierarchy in powerpivot with ID and Name. Use the hierarchy in the PivotChart category. Only ID field shows up initially. Expand entire field and the names show up. Hide level ID, and voila. You get all Names without ID column, but only to be used on smaller datasets.
datamodel,
easiest way to do this is created a calculated column in PowerPivot window where you will combine filename AND file id.
With that, it's very easy and still should be quite good from performance perspective. Better yet if you could prepare this column in your import file / on your server.
Result could then look like this:
From a data visualisation point of view it will be most confusing to have two data points with the same label and no means of differentiating them. So, having the ID in the X axis is actually helping the reader to make sense of the information.
From a technical point of view, you can create a chart that is based on the pivot table, but is not a pivot chart. Use the pivot table as the source for a regular chart and select only the Name as the X axis label.
If the pivot table dimensions may change when it is refreshed, you can use dynamic range names to ringfence the ranges required for the chart.
In the screenshot below, the label range chtLabels uses the formula
=OFFSET(Sheet1!$F$38,1,0,COUNTA(Sheet1!$F:$F)-1,1)
The range chtValues uses
=OFFSET(chtLabels,0,1)
When adding the range names to the chart source dialogues, they must be preceded with the sheet name or the file name.

How do I apply data filter to only the table range and not the whole row?

I have got two adjacent tables. When I apply data filter on first table, it filters the whole row hiding rows from 2nd table as well. How do I restrict filter to only the first table range?
To answer your direct question How do I restrict filter to only the first table range? the answer is - you can't.
Reading the comments it seems what you need is to display the filtered table data next to a chart and another table. There is a little know tool in Excel that you can use to achieve this - the Camera Tool. With this you can create a dynamic image of a range and place it where you want. The image updates when a filter is applied to the source range, without affecting the rows on the Dashboard sheet.
Screenshots to demonstrate:
Setup with tables on seperate sheets, and camera images beside chart on dashboard sheet
With Filter applied to Table A
The Camera tool is not on the Ribbon (Excel 2010) or the standard toolbars (Excel 2003). You need to add it using Customisation. (Add to Qucik Access Toolbar in 2010 or Tools/Customisation Menu in 2003)
Unfortunately you won't be able to do that. When you filter, it filters the entire row (something to think about would be how the row number would display if that weren't the case). You will need to restructure your setup if you wish to prevent that (not sure of your particular use case, so sorry I can't give a more specific suggestion).
I had a similar issue, where i had a table I wanted to remain static - like a key, but wanted to filter the main table.
To get around this, I copied the static table, and pasted it as an image. This way, when you filter on the main table, the image remains where you have put it.
A simple workaround for this general issue that others may have mentioned (but I don't see here):
You can't filter just a range (e.g. a few columns in a spreadsheet), but you can sort just a range. And by sorting the range, then deleting some blocks of unwanted cells in the range, then sorting the range back to the original order, you can fake a filter.
A bit clunky, but easy for some jobs if you're careful.

Resources