Excel Pivot Table Exclude one Row in Calculated Field - excel

In Microsoft Excel I want to have a pivot table that uses a calculated field for a row. I would like the calculated Row to exlude the current year. So I want two summary rows one with current year and one without. The attachment in orange shows my desired result.
I know I can manually make the cell formula for each month, but I would like it to be automatic. Any thoughts?

If your row variable was called "Year", your column variable called "Month", E1 was one of the cells in your pivot table and your values variable was called "Score", you could do something like
=GETPIVOTDATA("Score",E1,"Month","Jan")-GETPIVOTDATA("Score",E1,"Month","Jan","Year",YEAR(NOW()))
and repeat for each month.
However you would need to leave room under the table for it to expand to avoid over-writing your orange cells.
The only other way I can think of is the obvious one of copying the whole pivot table and filtering on row labels, excluding 2015.
You can copy a pivot table by selecting the whole table (can use Ctrl Shift *), right-clicking, selecting Copy and then pasting it somewhere else.
This is a mini-example showing the two methods.

Related

Excel Pivot - spanning field name across all relevant columns

I have a table of employees with their work location (state initials) and their work status (FMLA leave, part time, full time). I've made a pivot table so that I can see the number of employees in each state relative to their status. Making the pivot table is easy, and it looks like this:
My question relates to the column field name cell (highlighted in red). When the table is first created, Excel auto fits the columns. However, if you look at the picture, it is clear that ideally the FMLA, FT, and PT, columns should all be the same size for the table to look good. I can resize the columns, of course, and set the table to not auto size when it refreshes.
When I resize the columns the table now looks like this:
Two problems with the new layout. First, it is not clear at all that the "Employee Status" field name applies to all three columns FMLA, FT, PT. Second, with the first column being narrower "Employee Status" no longer fits. In Excel 2013, the field name is limited to just its column. In Excel 2016 it spills over to the next column, but has the filter pulldown in the middle of it! And of course the formatting doesn't spill over.
In a non-pivot, I would "merge" the three cells above the column headings and make "Employee Status" span all three cells. Leading to a much more intuitive look. However, "merge" cannot be used in pivot tables. My only work around at the moment is to Hide the row with the field name, and put a new row above it that is not part of the pivot table. Ends up looking good, but of course, it will not dynamically adjust if a new value is added to "Employee Status".
I'm looking for other recommendations on how to format this table so it ends up looking like this:
Ideally solution will work with Excel 2013, which unfortunately is what I'm limited to.

Add column to Excel Power Pivot Table based on slicer seection

I have an Excel Power Pivot Data Model with one table of about 3m entries. In one of my sheets I have multiple slicers that I combine to select entries that fit specific criteria.
I would like to add a column with a value that comes from a cell in the sheet, but only when the entry was part of the selection. For example: when the value in the cell is 1, the selected entries will get "1" in the added column. After that the number in the cell could be set to 2 and a new selection could be made. The new selection will all have "2" in the same added column.
I have been trying to make this work running a macro and DAX, but it can't get it to work. Anyone any ideas?
You can use the VBA I've previously posted at Converting multiple variables into values with excel pivot tables or power pivot to do that. It requires you to make up a 'harvester' PivotTable containing just the columns you want to swap out, so that you can then create a slicer from which to trigger the code.
You can also write a conditional formula in DAX that uses a harvester measure. Something like https://powerpivotpro.com/2012/11/one-slicer-to-control-them-all/ (and plenty of other examples on Google)

Excel Creating New Sheet with Summed Data from related sheet

Lets say I have the following on a sheet.
By some means, I want to either replace this, or preferably, create a new sheet, with the following data. Notice, that PO# is out of the picture, and a summation is done on rest of the fields. Is there a way to easily do this?
The end result has to be data in excel grid like below (preferably on a new sheet). This can possibly be some macro or some other technique I can use to easily create this....
You can easily do this with SUMIFS() or a Pivot Table.
For SUMIFS() the below equation will give you the sum for W.PS123 Product A. Modify as needed for your other criteria by swapping AR and product number (both housed in quotes in below formula, you can also set these equal to a cell range that contains desired criteria).
If you have a set number of "ARs" and Product Numbers, you will only need to build this table once and the equations will automatically update as your raw data changes.
=SUMIFS(C:C,A:A,"W.PS123",E:E,"A")
Alternatively, you can build a pivot table and just refresh this every time your data updates (or create a worksheet_change macro to refresh the table automatically when your data changes).
To build your pivot:
Highlight your table array (In your example, Col A-D)
Insert > Pivot Table
Drag AR to Rows
Drag PRODUCT to Rows (Below AR)
Drag QTY to "Values" and change the field to "Sum" rather the default count
Format to taste

How to automate a spreadsheet so that changing a value in one cell allows that entire row to appear in a separate tab of the worksheet?

Say I have a spreadsheet, as shown below:
Is there some kind of tool, add-in or formula, that would allow me to take all of the rows that are in 'July', and put them in a table in a separate tab:
In such a way that if I changed say 'COA' (the first row in the first picture) from January to July, it would automatically update the separate table to include this?
(Or at least be updateable with a click of a button or by refreshing)
My boss has asked me to see if this is possible, and I have no idea of how to go about it.
Thanks
It is possible.
In order to extract multiple items from a list you can use the INDEX function with SMALL to create an array formula.
Try the formula below. It assumes that the first column is A and column F contains the months.
=IFERROR(INDEX($A$2:$F$300,SMALL(IF(($F$2:$F$300="July"),ROW($A$2:$F$300)-1),ROW(1:1)),1),"")
IMPORTANT: use CTRL+SHIFT+ENTER when entering this formula to make it an array formula. You then need to auto fill down to get all the July records. This formula pulls data from column 1 (that's the last 1 in the formula). If your code in column 1 is unique to each row you can use a VLOOKUP to get the other columns. If it's not then you can copy the formula to the next column. And change the 1 at the end to 2..3 etc.
Instead of putting July in the formula you can reference a cell that contains July and then duplicate the sheet and change the cell to August or simply change the cell whenever you like to see data for different months.
It's not an easy formula to follow but it does work.
You could try doing a Pivot table with all the columns expect month in the rows section, using tabular view, no subtotals, and repeat item labels. Then put month in the filter section. Then you can update the pivot table by right click refresh or by clicking the refresh all on the data tab

Excel: transpose rows to columns and merge

I would like to present some data in Excel in a table. I have a sheet with three columns: date, time_spent and user_id. Every row is a data record. I want a table with a column for every date and every value with time spent below the date.
Using the transpose function under paste special I get this:
However I would like only one column per unique date, so the amount of columns decrease like this:
Does someone know how to do this?\
I have more than 10000 rows, so manually is too much effort...
Using Pivot Tables as Tim Biegeleisen suggested I cannot get what I want either, I'm not an expierenced user of Pivot Tables so probably I'm doing something wrong:
Excel file as shown in above picture
Here is one way of using a Pivot Table as suggested by Tim above in the comments, but you must use it on your original, non-transposed data: (and note which parameters go to which areas.
A disadvantage of the Pivot table is that the column headers are text strings and not dates. If your version of Excel is 2010+, you can use Power Pivot or Get and Transform to do a better job:
Open the Query Editor, change the format of the Date column, and Pivot the column:
Then Save the results:
Advanced filter dates to unique values in a new column
Copy and transpose them to make your column titles
Insert a new column B with the formula =TEXT(A2,"yyyyddmmm")&COUNTIF($A$2:A2,A2) and fill down
Below your new column headers put in the formula =IFERROR(VLOOKUP(TEXT(H$1,"yyyyddmmm")&ROW()-1,$B$2:$C$8,2,FALSE),"") and fill down and across. You will need to fill it down to cover the maximum number of instances of each date.
Adding a sumif to this table and your initial table would be a good way to check you got everything.

Resources