Solved

Excel 2010 graph with dynamic range columns

Posted on 2012-03-18
3
573 Views
Last Modified: 2012-06-07
Hi There,

I am trying to use the offset function with an indirect lookup for the first variable. (the aim being to populate a graph with a dynamic range calculated using a chosen start date and number of periods).


I have a formula that looks up the value of what needs to be in the reference variable for the OFFSET function:
="'Stat Table'!" & SUBSTITUTE(TEXT(ADDRESS(1,MATCH($Q$1,$4:$4,0),4),""),"1","") & ROW(D6)

Open in new window

(so this just looks up the Letter part that is unique to the chosen date and then the number of the column the offset is for).


I then reference it in the offset like this:

=OFFSET(INDIRECT(C5),0,0,,'Stat Table'!$Q$2)

Open in new window

But I get an error message of #VALUE! , any ideas? The offset value works if I just point it directly at the cell like this: =OFFSET(H3,0,0,,'Stat Table'!$Q$2) for example


Please see my problem attached
test1.xlsx
0
Comment
Question by:cookiejest
  • 2
3 Comments
 
LVL 50

Expert Comment

by:teylyn
ID: 37735722
Hello,

you don't need the helper cell with the cell address and you can avoid having to use Indirect() to build the range.

Set up two named ranges in the name manager:


chtXaxis      =INDEX('Stat Table'!$5:$5,MATCH('Stat Table'!$Q$1,'Stat Table'!$4:$4,0)):INDEX('Stat Table'!$5:$5,MATCH('Stat Table'!$Q$1,'Stat Table'!$4:$4,0)+'Stat Table'!$Q$2-1)
chtSeries1      =OFFSET(chtXaxis,3,0)

Then use the chtXaxis name for the X axis categories and the chtSeries1 name for the first series.

See attached.

cheers, teylyn
test1.xlsx
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 37735738
Similar approach to teylyn's, which dispenses with OFFSET as well as INDIRECT.

1) Created a sheet-scoped Name, ChartValues, with formula:

=INDEX('Stat Table'!$G$8:$X$8,1,MATCH('Stat Table'!$Q$1,'Stat Table'!$G$4:$X$4,0)):INDEX('Stat Table'!$G$8:$X$8,1,MATCH('Stat Table'!$Q$1,'Stat Table'!$G$4:$X$4,0)+'Stat Table'!$Q$2-1)

2) Created another sheet-scoped Name, ChartLabels:

=INDEX('Stat Table'!$G$4:$X$4,1,MATCH('Stat Table'!$Q$1,'Stat Table'!$G$4:$X$4,0)):INDEX('Stat Table'!$G$4:$X$4,1,MATCH('Stat Table'!$Q$1,'Stat Table'!$G$4:$X$4,0)+'Stat Table'!$Q$2-1)

3) Modified your chart to use the above Names as the source for both values and labels

4) Modified the x-axis to use a text label rather than a true date label
Q-27637787.xlsx
0
 
LVL 50

Accepted Solution

by:
teylyn earned 500 total points
ID: 37735777
I guess what's simpler comes down to preference.

I always use the long, complex formula to define the range for the X axis, then continue with Offset() to simplify the identification of the ranges for the data series.
Yes, I know that Offset() is volatile, but in a situation like this one, it's absolutely not noticeable and not worth getting my knickers in a twist, so I put readability and less typing over volatility avoidance.

Then again, with many chart series, the repeated use of the same Match() could be avoided altogether by using another named formula for the Match() portion, e.g.

firstWeek =MATCH('Stat Table'!$Q$1,'Stat Table'!$G$4:$X$4,0)
lastWeek =firstWeek+'Stat Table'!$Q$2-1

Then, if you prefer to spell out each series formula with a full fledged index, you can use something along the lines of

=INDEX('Stat Table'!$G$4:$X$4,firstWeek):INDEX('Stat Table'!$G$4:$X$4,lastWeek)

Again, this is not for speed, necessarily, but more for readability.

cheers, teylyn
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now