Dynamic stacked bar chart, with variable x-axis and categorical variables

SYKEMAKAVELI

New Member
Joined
Apr 18, 2023
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have a 11 (row) x 15 (column) table in Excel.
Cells A2:A11 are the categorical variables, and cells B1:O1 are time values that I want to have as the x-axis.
Cells B2:O11 are numeric values that I want to use for the stacked chart.

I want to create a stacked bar chart of the data.
I know how to make a stacked bar chart for static data, however the tricky bit here is that there could be blanks in both the categorical variables, or the time values, and I only want the graphs to show the values where there are no blanks.
For the rows, the blanks, if there are any, are always at the end (i.e. no leading blanks). However, for the time values, there can be blanks at either the beginning or end (but not both).
With new data, the location of the blanks can change for both the columns and rows.

I've tried to create a dynamic range name using the filter function to filter out blank values across the wider table, however it doesn't seem to work.
The only remaining idea I have is to use VBA to define the range location based on the first and last non-blank values in the table, and trigger a function to update the graph every time there is a change in the source data.

However, I'd prefer to do this without VBA if possible.
Does anyone have an idea of how I can dynamically create the graph?

Thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
i'm not really sure what you're asking for. It would be really helpful if you could mock up some data and post it using xl2bb (link below).
To show charts, I have to post an image (xl2bb won't capture charts). But, I've mocked up data in a shorter version but as I hope you've described.
For the blank cells in your data, use the =NA() function.

So, try this:

1693155762610.png
 
Upvote 0
Hi awoohaw,
Sorry about that. Please see my attempt to put two examples into XL2BB below. For some reason it's not showing the graphs in the Preview, so I've also attached them as images.
As you can see:
Example 1 - I would just want the graph to cover the range from June 22 - Oct 22, and for the categories up to, and including, 'PD'.
Example 2 - the range has shifted such that it's from Aug 22 - Jan 23, and for all categories up to 'VC'.


I'm looking for a (hopefully non-VBA) way of setting up dynamic chart references so that the stacked bar chart will automatically update based on the structure of the data that is put through the table. Note that the included categories will always cover the first 'n' rows. i.e. I wouldn't have any leading "N/A" rows. However, per the example, I can have leading or lagging NA (date) columns, but they're then always in groups thereafter. So effectively the data is always in a rectangular format, but the position of the rectangle can shift across or lengthen downwards to include more categories.

Thanks in advance.


Book10
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAE
1Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22Jan-23Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22Jan-23
2BS98995#N/A#N/A#N/ABS#N/A#N/A899559
3DR68677#N/A#N/A#N/ADR#N/A#N/A867777
4EX79796#N/A#N/A#N/AEX#N/A#N/A979669
5LK57789#N/A#N/A#N/ALK#N/A#N/A778998
6LY85566#N/A#N/A#N/ALY#N/A#N/A556666
7MC68659#N/A#N/A#N/AMC#N/A#N/A865995
8PD66799#N/A#N/A#N/APD#N/A#N/A679999
9VC#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/AVC#N/A#N/A679999
10WW#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/AWW#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
11XT#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/AXT#N/A#N/A#N/A#N/A#N/A#N/A#N/A#N/A
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31So I don't want any bars to appear for "VC", "WW" and "XT". I also don't want any rows for Nov-22, Dec-22 and Jan-23In this example, I wouldn't want any bars containing "WW" and "XT", but I would for "VC" given that there's data. The date values would now range from Aug-22 to Jan 23
32
33
34
Sheet1
Cell Formulas
RangeFormula
G2:I8,P10:W11,B9:I11,P2:Q9G2=NA()


1693175677817.png
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,171
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top