+ Reply to Thread
Results 1 to 8 of 8

Using the IF, Else function when createing a Pivot Chart in VBA

  1. #1
    Registered User
    Join Date
    05-25-2016
    Location
    Erlanger, KY
    MS-Off Ver
    2010
    Posts
    81

    Using the IF, Else function when createing a Pivot Chart in VBA

    I have a pivot chart that was created from a pivot table. there are two columns, 2015 and 2016. The chart has weeks 1 through 52. I need to create a chart that will populate as data is added to week 2016. Right now the chart shows large values for 2015 and of course small values for 2016 because We are currently in 2016. I need to be able to display YTD values..which will only show values up to the current week that we are viewing.. If I were to enter a regular function if function, it would basically say... If value in 2016 is blank or 0 do not include the value from 2015 in the totals.. I'm sure this can be done in vba coding, but can't determine how to do it so that the chart updates as the pivot table updates.

    I hope I am making since to you. I created a macro that creates the pivot chart... I just need to know how to do the rest. Here is the Macro...When creating it I randomly removed weeks 50, 51,52 just to see how excel references them.


    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Using the IF, Else function when createing a Pivot Chart in VBA

    I would suggest making a PROCESSED_DATA worksheet that does this for you with EXCEL logic, then you can link your chart to THAT data.

    Raw data -> Processed Chart Data -> Chart
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Registered User
    Join Date
    05-25-2016
    Location
    Erlanger, KY
    MS-Off Ver
    2010
    Posts
    81

    Re: Using the IF, Else function when createing a Pivot Chart in VBA

    I'm sorry, I am not following you!

    Can you explain what you mean.

  4. #4
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Using the IF, Else function when createing a Pivot Chart in VBA

    Use EXCEL to process the data before you put it in a chart, instead of using VBA.
    Create a dataset that takes care of the YTD calcs. Then use THAT dataset to make the chart, instead of the RAW data.

  5. #5
    Registered User
    Join Date
    05-25-2016
    Location
    Erlanger, KY
    MS-Off Ver
    2010
    Posts
    81

    Re: Using the IF, Else function when createing a Pivot Chart in VBA

    I wished it where that easy. The data needs to automatically grow... so when data is added to the source, it will change the pivot table. I tried creating a secondary data source and create just a regular chart from that... it didn't work either.

  6. #6
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Using the IF, Else function when createing a Pivot Chart in VBA

    Then add the logic to the raw dataset in a formula. I disagree with your statements generally but I have no idea what you are working with.
    I have done this before multiple times with excel and/or pivot tables and/or powerpivot and/or VBA always looking for the most simple solution.

    Attach a sample workbook if you want more specific advice. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  7. #7
    Registered User
    Join Date
    05-25-2016
    Location
    Erlanger, KY
    MS-Off Ver
    2010
    Posts
    81

    Re: Using the IF, Else function when createing a Pivot Chart in VBA

    I attached a copy of some of the data. There is a total of 10 Product lines. I only attached 2. I could not reproduce what This has a pivot chart. If you look at the columns you will see where 2016 ends. I need to know how to tell the system to not include 2015 data if there is no data in the 2016 column. I hope this is what you need.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Using the IF, Else function when createing a Pivot Chart in VBA

    So I am not exactly sure what you are trying to do but I showed you a step in the right direction.

    Find the MAX week number in 2016 that has data, I used a pivot table for that but there are plenty of ways. Then use that to include the data in a YTD_VALUE column in the raw data.
    Then you can pivot and see just what you want.

    If you wanted you could THEN use VBA to pull out anything that is NOT 0 in the YTD calc and pivot on THAT data for a clean chart.


    Previously I think I used PowerPivot to do the heavy lifting for this the last I solved it.

    Also if you save a large file as .XLSB it compressed it more so you don't have to zip it.
    Attached Files Attached Files

+ 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. Chart order in trad. Pivot Chart vs. PowerPivot chart
    By mr_jules in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 01-06-2015, 11:17 AM
  2. [SOLVED] Createing Email from Userform - Body of email contain content from textbox
    By honger in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2014, 08:44 PM
  3. Replies: 2
    Last Post: 01-10-2014, 02:02 PM
  4. Createing pivot table
    By denfan in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 01-11-2013, 02:44 PM
  5. Createing a slider to enter a value in a cell
    By sintax69 in forum Excel General
    Replies: 0
    Last Post: 07-05-2012, 04:11 AM
  6. Pie chart handles in the pivot table don't function
    By hazel in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 07-16-2006, 07:25 AM
  7. [SOLVED] createing a list
    By Hot rod in forum Excel General
    Replies: 2
    Last Post: 04-05-2006, 04:00 PM

Tags for this Thread

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