+ Reply to Thread
Results 1 to 4 of 4

Change calculated field in pivot based on option button

  1. #1
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Change calculated field in pivot based on option button

    Morning - hoping this is a quick and easy fix!

    I have an option button on the same sheet as a pivot table. The pivot table has two similar calculated fields currently

    Within SLA % = 'Within SLA' / Projects
    Outside SLA % = 'Outside SLA' / Projects

    What I want is to toggle both calculated formula between /Projects and /Jobs by clicking the option button.

    The code I currently have is not working:

    Please Login or Register  to view this content.
    Am I going about this the right way or is there a better option?

    TIA

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Change calculated field in pivot based on option button

    Here's my suggestion. On the pivot table page, have a data validated box that has "Within SLA" and "Outside SLA" as its choices (Cell B1 on sheet Pivot for the sake of example). In the source data for the pivot table, create a helper column called Numerator with the formula: =IF(Pivot!$B$1 = "Within SLA",[Within SLA],[Outside SLA]). Then the calculated pivot table formula becomes Numerator / Jobs.

    Toss in a change event on Pivot!B1 to refresh the pivot table when it's changed.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: Change calculated field in pivot based on option button

    Thanks for the good suggestion (hadn't actually thought of this). Having tried it out though I've found an issue is that I have freeze panes on the adjacent column (yes, I could move this but it'd then keep a random column of data in view, which looks awful, and I can't amend the columns in the table underneath as it's a pivot). If the sheet is scrolled to the right, the drop-down box for the data validation does not appear as it is hidden behind the frozen column... Users would be very confused by this and claim it's not working and they're unable to select what they want...

    Edit:
    I just found this - https://www.mrexcel.com/forum/excel-...vot-table.html
    I don't really understand it well enough though, but maybe I can use it for what I want?
    Last edited by dancing-shadow; 07-06-2017 at 06:39 AM.

  4. #4
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: Change calculated field in pivot based on option button

    I've done it, although it could probably be written in a better way. Decided to delete the calculated field altogether and re-create it with the formula I need. So I have 2x macros (one for each option) - one calculates on Jobs, the other on projects.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Pivot Table: Calculated Field based on Running Total Field
    By EvolvingMonkey in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-07-2016, 06:27 AM
  2. Group option and calculated field option greyed out on pivot table
    By KevinMolina in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-16-2015, 05:00 PM
  3. [SOLVED] Using Calculated Field to Express % Change in Pivot Table Columns
    By eadamquinn in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 06-17-2015, 11:32 PM
  4. Pivot Table-Calculated Field option
    By RobertMika in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-30-2012, 07:01 AM
  5. Replies: 0
    Last Post: 06-26-2012, 09:06 PM
  6. Replies: 0
    Last Post: 07-10-2010, 03:02 PM
  7. Replies: 0
    Last Post: 02-04-2010, 07:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1