Associating a cell outside a pivot table with one within it - excel - excel

I'm currently creating a Pivot table in excel with several filters which read in rows.
What I need to do is associate a cell that sits outside of the pivot table, with the row of content within the pivot table. So that whenever a filter is applied within the pivot table the content outside it behaves in the same way.
I don't want the values/text within the cells to change - just to follow the behaviour of the filtered content in the table.
I've tried to add this 'outside' info to the pivot table but it just makes it over complicated.
Please can anyone help? Is this even possible?

hard to answer without knowing exactly what you're trying to do however using the GETPIVOTDATA formula may achieve your desired result
(https://support.office.com/en-gb/article/GETPIVOTDATA-function-026db7b1-dd6f-4057-9396-2c2798d159db)
=GETPIVOTDATA("Value",$B$9,"Row Label","Row Value")
"Value" = the name of the field you want to return a result for
$B$9 = location of any cell in the pivot table
"Row Label" (optional, repeatable) = field that you want to filter by from row labels (if left blank will return grand total)
"Row Value" = value of filter applied to Row Label, can be a formula e.g. if row labels are in column B and you want the filter to relate to whichever value is on row 10 you can use B10
changing the values in your report filter will edit the result of this formula

Related

How to get dynamically the last value from a pivot table in Excel

I have a pivot table like the one in the image:
The table updates every month.
The question is: how can I dynamically get the last value of the table with a function, without VBA?
For example, in this case the last value is -32, just above the "Grand Total" value.
I'm considering to use the function "GETPIVOTDATA" but I don't know how to change the dynamic reference to the last value inserted. At the moment, the formula looks like this:
=GETPIVOTDATA("[Measures].[Count of DESIGNER]";$A$3;
"[Components_Drawings_Data].[DATE (Month)]";
"[Components_Drawings_Data].[DATE (Month)].&[giu]")
Screenshot (below) / here refer.
Assuming:
You can isolate the pivot table so that there are no populated cells
beneath it (reasonable premise, given it's 'dynamic' and so variable
re: # rows)
You're not fixated upon using a PivotTable reference in formula
You do not anticipate any row labels = 'Grand Total' (which would be unusual to say the least, however see alternative function below)
Grand total for columns is displaying
Then the following will achieve what you have indicated:
...how can I dynamically get the last value of the table with a
function, without VBA?
=OFFSET(INDEX($F$4:$F$100,MATCH("grand total", LOWER($F$5:$F$101),0)),0,1,1,1)
Note: the formula in cell L3 in above screenshot includes a wrapper for presentation / ease of use only - i.e. 'Item' (col J) refers to the number of cells 'up' from the Grand Total at the very bottom of the pivot table... e.g. for item = 1 (one level up), 119 is returned (corresponding to 'woman'); for item = 2 (two levels up, 77 displays and so forth.
The corresponding label can be determined in a very similar fashion:
INDEX($F$4:$F$100,MATCH("grand total", LOWER($F$5:$F$101),0)-J3+1)
Alternative/direct (does not rely upon Grand Total for cols):
=OFFSET(F3,COUNTA(F3:F100)-2,1,1,1)
I elaborated this trick.
Suppose the column "Month" of the pivot table corresponds to column A, and the column "Delta" to column B.
I would use this formula:
=INDEX(B:B;MATCH("Grand Total";A:A;0)-1)
It could work.

How to filter multiple values

In the image down below I have an example.
There are 2 columns with name Clientnumber. What I need is that the values under Clientnumber1 are filtered from Clientnumber and are Printed in a third sheet. In this example the filtered values are printed under the column Filtered. So the sales are included. Does anyone know how to do this?
What you need is advanced filter. Activate the third sheet - the one where you want the filtered data. Then select advanced filter (Data - Advanced [next to filter]) Select: Copy to another location. Select the table you want to filter as list range. Select the values you want to get as a criteria range (note that you'll have to change the title of the criteria column to match the title of the column in the table - from Clientnumber1 to Clientnumber in your case. Finally for copy to you select a cell in the third sheet.

Excel PivotTable Count field as % of another Count field

I am using Excel from Microsoft Office 365 ProPlus.
Here's a really simple data table.
I want to build a Pivot Table around it to look like this...
... except that the "what I want" column (which is the count of items in Column C divided by the count of items in Column B) should be a part of the pivot table.
I have tried all sorts of things using calculated fields, calculations on fields, etc., to add the "what I want" column and just cannot make it work.
Can anyone help?
Calculated Fields only operate on the Sum of the elements in the data tables. Wherever you see a Field Name in the formula for a Calculated Field, picture it as meaning the sum of all elements for that field (that match any other row/column criteria in the Pivot Table).
Putting "= B / C" actually means "= SUM(B) / SUM(C)" for elements of columns B and C that fit that section of the Pivot Table.
The only way to achieve your goal is with two helper columns:
B Count: =COUNT([#B])
C Count: =COUNT([#C])
The sum of these columns then give you the count of columns B and C, so you can use these helper columns to give you what you want:
The Data Field based on the Calculated Field then says "Sum of What U Want", but it will always just be the result of your calculation, even if you change how the field is summarized through Value Field Settings. You can manually rename the Data Field, but it still needs to be different to the Calculated Field name you chose earlier.
Click in the Pivot Table, then go to the Analyze tab, click on Fields, Items, & Sets, then select Calculated Field. Your formula is probably
= B / C

Count of distinct values with several criteria

I want to be able to count distinct values with several criteria. As presented here below on the screenshot, I would like to know, how many POs do I have per month depending on the PO type (service or material).
Initial data:
Desired result:
All the data is in text format.The difficulty is that the initial data table will be updated every month (I will be adding lines), so the formula has to consider possible updates. Pivot table will not work for me.
The solution I'm offering involves one helper column, but you'll be able to use it quite flexibly. I make the following assumptions:
You can add columns to your original table
The table starts in cell A1
Steps:
Convert your data range into a dynamic excel table (select the range, press Ctrl+t, tick "Table Has Headers" - you get a blue table as a result). This way if you add more data, formulas will drag themselves down.
type "HELPER" into cell D1, and "Number of POs" into cell E1 - this will create 2 new columns (they should turn blue like the rest of table)
paste this formula into cell D2:
=[#[Month/Year]]&[#[Mate/Serv]]
Paste this formula into cell E2:
=SUMPRODUCT(
( [HELPER]=[#[Month/Year]] & [#[Mate/Serv]] ) /
COUNTIFS([Month/Year],[Month/Year],
[Mate/Serv],[Mate/Serv],
[PO No.],[PO No.]
)
)
Add a pivot table, put Number of POs into values area, it will sum values by default.
As in this picture:
Right-click inside the values area, select Summarise Values By.. => MAX (as in second picture below).
You will see that values in pivot have changed.
this way you won't have to manually maintain the header in your summary table as pivot table will pick up any new entries/months.
IF YOU WANT TO STICK TO YOUR ORIGINAL DESIGN:
The same formula can be used (with minor change to add table name to column names), but it still needs the table and helper - follow steps 1-3. Make sure you're set up is as in picture below:
=SUMPRODUCT(
( Table2[HELPER]=H$1&$G2 ) /
COUNTIFS(Table2[Month/Year],Table2[Month/Year],
Table2[Mate/Serv],Table2[Mate/Serv],
Table2[PO No.],Table2[PO No.]
)
)
If anyone would like to change my formula to avoid creating a helper, please do.
I created a dummy table so your results won't be like mine.
How to test:
Copy your data on a new sheet
Go to Data menu ribbon => Remove Duplicates
Pivot the remainder
Put met/serve into rows, month/year into columns, Helper into Values.
That will give you a count you should expect.
Assuming your data is in Columns J:L, you can add a helper column in M, entering this formula in M2 and dragging down:
=COUNTIF(J:J,J2)
Then, assuming your desired result table is in columns N:P enter this formula in O2:
=COUNTIFS($K:$K,O$1,$L:$L,$N2,$M:$M,">0")-MAX((COUNTIFS($K:$K,O$1,$L:$L,$N2,$M:$M,">1")-1),0)
You can then drag this cell over to column P and drag them both down.
This also assumes you Desired result table headers are formatted as text as well.

Autofill column of an Excel table based on another column

I've created a table with multiple columns in Excel, and I'm trying to let it autocomplete some columns based on another one: There's an "Item name" column and a "Item type" one, and I want to make excel autofill the Item Type field on every row based on the entry in the Item name field on the same row, is there a way to make Excel handle this by itself based on previous entries?
EDIT: Example for clarity:
If I insert "Pizza" in Item Name and "Food" in Item type, when I enter "Pizza" again in another row, Excel auto-fills the same row "Item type" field with "Food"
Based on your edit you want the vlookup function.
VLOOKUP( value, table, index_number, [not_exact_match] )
If index_number is less than 1, the VLOOKUP function will return
VALUE!. If index_number is greater than the number of columns in table, the VLOOKUP function will return #REF!. If you specify FALSE
for the not_exact_match parameter and no exact match is found, then
the VLOOKUP function will return #N/A.
But first you'll need to make sure that these associations are already present. You need a table like this. Assume that 'object' is a1 and 'type' is b1:
Object Type
Pizza Food
Car Vehicle
Now for your table that you're entering the values, assume that 'name' is d1 and 'type' is e1:
Name Type
Pizza =vlookup($d2, $a$2:$b$99, 2, false)
Car =vlookup($d3, $a$2:$b$99, 2, false)
The '$' will prevent the relevant cells from changing if you use autofill to complete the column.
If this is a set list that is relatively short you can manually enter it into the autfill options.
Microsoft gives you all the various ways to do this.
https://support.office.microsoft.com/en-us/article/Fill-data-automatically-in-worksheet-cells-74e31bdd-d993-45da-aa82-35a236c5b5db?CorrelationId=99c7dec0-4c5c-4988-b148-6d3b7c4dd2e5&ui=en-US&rs=en-US&ad=US
Also, creating a pivot table may be what you want to do. Simply highlight your main table and go to the insert table and click pivot table. Move the headers into the appropriate box.
The last option may be your best bet if it involces a ton of values. lookup/match functions will give you a more robust formula that is more versatile.
If you can give a sample set of data and what you want it to look like I can give you the formula.

Resources