+ Reply to Thread
Results 1 to 6 of 6

How to create stacked bar chart / quartile chart with negative starting value

  1. #1
    Registered User
    Join Date
    05-06-2023
    Location
    England
    MS-Off Ver
    Office 16
    Posts
    2

    How to create stacked bar chart / quartile chart with negative starting value

    Hello everyone,

    I am trying to recreate the quartile chart shown below in Excel, however I'm having trouble with the 1-year bars due to the negative value of the lower bound (i.e., bottom quartile).

    Is it possible to chart this data in Excel to be shown in the same way?

    Stacked bar chart.png

    Please see a copy of the data and my attempt at creating the chart in the Excel file attached.

    Stacked bar chart.xlsx

    Thanks in advance for your help!

    Shaun

  2. #2
    Forum Contributor
    Join Date
    09-03-2016
    Location
    Catania, Italy
    MS-Off Ver
    Excel 2019
    Posts
    164

    Re: How to create stacked bar chart / quartile chart with negative starting value

    HI

    In the example you have attached, the "Top.Quartile" series of the Chart is unfilled and, therefore, not visible but starts below 0 (zero).

    HI,
    Mario

  3. #3
    Registered User
    Join Date
    05-06-2023
    Location
    England
    MS-Off Ver
    Office 16
    Posts
    2

    Re: How to create stacked bar chart / quartile chart with negative starting value

    Hi Marius,

    Apologies, I should have been clearer in my original post.

    I am trying to replicate the chart attached below but in an Excel spreadsheet. The issue I have relates to the 1-year column. Specifically, the bottom quartile, 3rd quartile and 2nd quartile (lower bound) are all less than zero and so I don't think it's possible to use a stacked column chart to replicate the chart, but was wondering if there were any other suggestions on how this can be achieved?

    Chart to replicate.png

    For additional context, I had intentionally hidden the "top quartile" data series in my chart in order to match the chart I am trying to replicate. This works fine for time periods where the lower bound of the bottom quartile is positive (i.e., for all time periods except the 1-year), but not where the lower bound of the bottom quartile is negative. This is because zero is the fixed starting point.

    I believe there is a way to adjust the starting point up or down for a data series, however this would move the entire data series (i.e., the same quartile for each time period) which is not the intention here.

    I hope that helps and thanks for your interest in helping - much appreciated.

    Many thanks,

    Shaun

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

    Re: How to create stacked bar chart / quartile chart with negative starting value

    I cannot find good documentation for the behavior of stacked bar/column charts with negative values. As near as I can tell, negative values stack beneath each other starting at 0 and positive values stack on top of each other starting at 0. I know of no way to change this behavior in Excel (not sure about other charting applications), so you will need to program the spreadsheet to handle quartiles that cross 0. After studying the behavior of stacked column charts, here's what I ended up doing for your data:

    1) Since 0 is the "hinge" point for the different stacking algorithms, I add a 0 value to the source data. Enter 0 in B9:G9.
    2) I want to see the data sorted, so I sort the data. My older version doesn't support the SORT() function, so I use the LARGE() function to sort from large to small.
    2a) Enter 1,2,3,...6 in A19:A24.
    2b) Enter =LARGE(B$4:B$9,$A19) in B19, note the mix of relative and absolute references, and copy/paste/fill into B19:G24.
    3) I want to know where the 0 is. I choose the RANK() function for this. Enter =RANK(0,B$4:B$9,0) in B26 and copy/paste/fill into B26:G26.
    4) Now, starting where 0 is, I want to work "down" from 0 and calculate the differences/lengths of bars for all negative entries. In order to make some chart formatting easier later, I'm going to do some extraneous calculations that result in errors.
    4a) I want to start where 0 is, so I enter =B$26 in B28. Counting down from 0 is adding rows, so I enter =B28+1 in B29. There are 6 total, so I copy B29 and paste/fill into B29:B34. Select B28:B34 and copy/paste/fill across to column G.
    4b) I can use INDEX() to pull the appropriate values from rows 19:24, and subtract. (Leaving room for some above 0 stuff), I enter =INDEX(B$19:B$24,B29)-INDEX(B$19:B$24,B28) into B42. Copy/paste/fill into B42:G46. Remember that there will be several errors in this range, but the errors should not impact the final chart.
    5) Starting where 0 is and work up through the positive values.
    5a) Select B28:G28 and copy into B35:G35. In B36, enter =B35-1 and copy/paste/fill into B35:G40.
    5b) Again, use INDEX() to extract the appropriate values from 19:24 and subtract. This is the same formula as 4b, so select B42:G46 and copy into B48:B52.

    6) Now I have all of the bar lengths calculated in rows 42:52, with errors where there is no bar length to be calculated (the chart will treat the errors as if they are 0). I can now create my stacked column chart. Select B1:G1 <ctrl> B42:G52 -> insert stacked column chart.
    7) Because 0 is not a real data point in the chart, I really want the first negative series and the first positive series to look the same so that the reader will see that this is the same quartile. This is part of why I did separate count down from 0 and up from 0 sections. I wanted the first negative series and the first positive series to always be in the same row (in this case, rows 42 and 48). Select the series associated with row 48 and format this series so it looks like row 42 (or 42 so it looks like 48, or some other combination of both so that these two series look the same).
    8) Add rows 2 and 3 as line chart series to complete the combination chart. Format other chart elements as desired and evaluate the result.

    It's a lot of hoops to jump through to get the same kind of behavior that stacked line and stacked area charts do automatically. You just need to understand how stacked column/bar charts work with negative values, then adapt your spreadsheet to make the right calculations that go with the chart behavior.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Contributor
    Join Date
    09-03-2016
    Location
    Catania, Italy
    MS-Off Ver
    Excel 2019
    Posts
    164

    Re: How to create stacked bar chart / quartile chart with negative starting value


  6. #6
    Forum Contributor
    Join Date
    09-03-2016
    Location
    Catania, Italy
    MS-Off Ver
    Excel 2019
    Posts
    164

    Re: How to create stacked bar chart / quartile chart with negative starting value

    HI
    I tried to create the Chart in a "traditional way". I added the series "zero" below in your table and in cell B9 I entered this formula =IF(B8>=0,B8,0) and copied it up to G9.
    This series has no fill.
    Let know.

    HI,
    Mario
    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. create stacked bar chart
    By smattiko in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 03-31-2023, 03:53 PM
  2. Question: Stacked Bar Chart with negative value
    By oldmangloom in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-09-2013, 04:46 PM
  3. Stacked Bar Chart with negative values, and the net total matters!
    By shannon2244 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 09-24-2012, 10:16 AM
  4. Stacked Area Chart - Negative Values
    By sagaramlani in forum Excel General
    Replies: 8
    Last Post: 09-05-2012, 12:54 PM
  5. How to Create a Stacked Bar and a Bar within same Chart
    By AllisonT in forum Excel General
    Replies: 0
    Last Post: 06-29-2012, 07:24 PM
  6. [SOLVED] Stacked area chart with one negative data series needed to be shown separately
    By Ivkosky in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-11-2012, 03:50 AM
  7. [SOLVED] To create a stacked column chart and group the stacked bars togeth
    By Jacqueline in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-18-2005, 10:06 AM

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