Search code examples
excelexcel-formulapivot-tableslicersvba

Excel - Pivot Slicer or Via VBA?


I am posting this to all Excel Champs and Code Experts. I am familiar with Pivot and Slicer feature of excel however came with an requirement and I could not think of any way I can achieve it via pivot ( preferably )

The Requirement is like this. I have team data in col 1 and Sales figures in col 2. Now with a simple pivot, I can have the team totals and things like that but I need to put in slicer on team name. If I select Team one , it should show Team one sales against total of other three team . PLease advice if there is a way to do that. In summary I need to compare a person's /team performance against total peers

Team Sales One 20000 Two 15000 Three 500 Four 35000 One 500


Solution

  • You can achieve this with formula next to your PivotTable values. You will use formula against your total range of values in col2. If your columns are set to range A:B, and PivotTable is in range D:E, then put this formula =E2/(SUM($B$2:$B$30)-SUMIF($A$2:$A$30,D2,$B$2:$B$30)) in cell F2. You should get result as follows.

    enter image description here

    If you need to have result inside your PivotTable, then you should use PowerPivot and create a measure. try looking at this for more info: https://msdn.microsoft.com/en-us/library/gg399161(v=sql.110).aspx