+ Reply to Thread
Results 1 to 13 of 13

Change Chart Series Collection Name in a Pivot Chart

  1. #1
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Change Chart Series Collection Name in a Pivot Chart

    Hello,

    How can I change the chart series collections names in a Pivot Chart? With below code I am able to change a normal chart (without being a Pivot Chart):

    Please Login or Register  to view this content.
    Any idea? Thanks!

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Change Chart Series Collection Name in a Pivot Chart

    Pivot charts have many restrictions and limitations. I cannot be sure, but I expect that this is one of them -- the data series name must be linked to the column headings in the pivot table.

    What is your end goal in changing the name? Why do you want the series name to be different from the column name in the pivot table? I expect that, in order to do this, you will need to create a normal chart from pivot table data (and do it in a way that makes certain that the chart is not converted by Excel to a pivot chart). See this essay: http://peltiertech.com/regular-chart...-pivot-tables/
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Change Chart Series Collection Name in a Pivot Chart

    It is because the chart legend label is set too big, for example, one of the series (I have many) is the following, as an example:
    "XPTO - Average of COMPLEX_UTIL_PCT"

    I need to simply have "XPTO" in the chart legend/series name.

    I believe this can be done with changing Pivot Field Caption name. In fact I tried something like this:

    Please Login or Register  to view this content.
    But, I am having two problems, one is I get the error "PivotTable field name already exists", and the other is that I am unable to remove the dash (-) on series name. So for example, with the series name "XPTO - Average of COMPLEX_UTIL_PCT", it gives me "XPTO -".

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Change Chart Series Collection Name in a Pivot Chart

    I have little expertise with pivot tables and charts. It appears to me that the legend text is linked to the column headers in the pivot table, and the column headers in the pivot table are linked to the text in that field in the source data. My thought would be to edit the source data so that the text in this field is shorter, or add an additional column/field ("short name") and enter the desired abbreviated text in this field, then use this field as the column headers.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Change Chart Series Collection Name in a Pivot Chart

    It is not possible to have more than one field with the same caption, which is what your code would produce. You also cannot use the name of a pivot field as its caption- it must be different in some way. You might perhaps use something like this
    Please Login or Register  to view this content.
    which will take everything up to the first space in the current caption, and prefix that with a space purely to make it (hopefully) different from the field name.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  6. #6
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Change Chart Series Collection Name in a Pivot Chart

    xlnitwi, with the code you posted, now I am getting: XPTO - Average

    Do you have any idea on how can I eliminate the "Average" word and possibly the dash?

    Thanks!!

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Change Chart Series Collection Name in a Pivot Chart

    It seems those are not spaces. Perhaps this
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Change Chart Series Collection Name in a Pivot Chart

    xlnitwi, in fact, I believe the dash is not part of the Pivot Field Caption, not sure if it is possible to remove that or not. Maybe it is part of another set of the Pivot Field?
    I tried your above code, but did not make any effect.

  9. #9
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Change Chart Series Collection Name in a Pivot Chart

    If you are seeing it, and the code changes it at all, it must be part of the caption. Can you provide a sample workbook?

  10. #10
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Change Chart Series Collection Name in a Pivot Chart

    The file is attached, can you see this?

    sample_pivot.xlsm is the file name.
    Attached Files Attached Files

  11. #11
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Change Chart Series Collection Name in a Pivot Chart

    Here's what I tried

    1) Select a cell in column G of the pivot table
    2) PivotTable Tools -> Field Settings -> Custom Name -> Enter a suitable shorter text string (I used "a" and " " to test. It will not let me put nothing).
    3) Not only did this change the text in G5, but it also changed the text in every "Average of COMPLEX_UTIL_PCT" column and data series.

    If the main concern is the length of the text string, this looks like a simple, built in, non-VBA way to alter the text to whatever you want (except a true blank)

    I know that is a completely different approach than what has been discussed, but will that be adequate?

  12. #12
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: Change Chart Series Collection Name in a Pivot Chart

    MrShorthy, it worked, but, the dash is still there in the Pivot Chart... Is there any way to remove the dash?

  13. #13
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Change Chart Series Collection Name in a Pivot Chart

    Your question assumes that I know more about manipulating pivot tables than you do. I did not know about this "custom name" option until today looking over your sample pivot table, right clicking on stuff until I found the "field settings" dialog, and found the custom name field in that dialog. My only recommendation at this point is to continue exploring option dialogs to see if an option for "don't combine multiple level column headings into a pivot chart legend entry" exists anywhere. To my knowledge, it does not exist, but I am not that familiar with pivot tables/charts.

+ 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. Radar chart series collection
    By EmmaEmu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-13-2013, 12:28 PM
  2. Chart front-to-back series display if series are different chart types
    By Exconomist in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-06-2012, 06:49 AM
  3. Replies: 2
    Last Post: 12-23-2011, 11:04 AM
  4. Conditional Series Collection Colour for Chart
    By benno87 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-24-2009, 09:54 PM
  5. Replies: 6
    Last Post: 02-19-2009, 07:57 AM
  6. Change Chart Series with VBA
    By Sueann in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2006, 04:57 PM
  7. help me to change the color of two series in a chart into the same
    By KhanhNguyen in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-20-2006, 11:48 PM
  8. Change series in a chart
    By trispirit32 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-26-2005, 02:05 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