+ Reply to Thread
Results 1 to 5 of 5

automatically show data for 3 weeks before & after current week in graph

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-16-2010
    Location
    Phnom Penh, Cambodia
    MS-Off Ver
    Excel 2003
    Posts
    216

    automatically show data for 3 weeks before & after current week in graph

    Hi,

    I have the week number of the year, and i am on WEEK6 now. Even though i have the focus vs. actual completion for the whole year (52 weeks), i would like to show only 7 weeks for focus vs. actual completion on my line graphs..

    i.e: i am now on WEEK6 so the data on my graph should be only W3, W4, W5, W6, W7,W8,W9 (Week = W).

    and let say i am now on W10, so my graph should display W7, W8, W9, W10, W11, W12, W13

    I can do this manually by editing my graphs every Monday start of the week. However, i would like this to be automated because i will have more than 10 graphs for show the progress of my work.

    I have attached a graph with its data which is very much similar to my real worksheet.

    Please kindly advice. Your comments will be very much appreciated.
    Attached Files Attached Files
    Last edited by sanlen; 02-14-2011 at 08:44 AM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: automatically showing data for 3 weeks before & after current week in graph

    Hello,

    you can do that with dynamic ranges.

    Define a range name called currWeek and assign it the formula =weeknum(today())

    Then create three named ranges called
    chtXLabels =INDEX(Sheet1!$2:$2,MATCH("W"&currWeek,Sheet1!$2:$2,0)-3):INDEX(Sheet1!$2:$2,MATCH("W"&currWeek,Sheet1!$2:$2,0)+3)
    chtAC =OFFSET(ChtXLabels,2,0)
    chtFC =OFFSET(ChtXLabels,1,0)

    Edit your chart series to refer to

    FC =sheet1!chtFC
    AC =sheet1!chtAC

    and set the chart X axis labels to refer to

    =sheet1!ChtXLabels

    Now, when the week number changes, the chart will update.

    You can test this by letting the range name currWeek refer to a cell where you can enter the week number manually.

    see attached.

    cheers,
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    03-16-2010
    Location
    Phnom Penh, Cambodia
    MS-Off Ver
    Excel 2003
    Posts
    216

    Re: automatically show data for 3 weeks before & after current week in graph

    Hi,

    I am trying to adapt your guidance to my actual worksheet, however, i cannot get it worked. I always get error. I have attached another worksheet with those formulas that i have tried.

    Could you please advice?
    Attached Files Attached Files

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: automatically show data for 3 weeks before & after current week in graph

    change the formula for the range name chartXlabels to

    =INDEX(Week_Number!$2:$2,MATCH("W"&currWeek,Week_Number!$2:$2,0)-3):INDEX(Week_Number!$2:$2,MATCH("W"&currWeek,Week_Number!$2:$2,0)+3)


    Going forward, it may be a good idea not to use range names that start with "chart". Later versions of Excel consider this as a reserved name. Use "cht" instead, as in my examples above.

    See attached with the named ranges working and applied to the two empty charts you attached.

    cheers,
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    03-16-2010
    Location
    Phnom Penh, Cambodia
    MS-Off Ver
    Excel 2003
    Posts
    216

    Re: automatically show data for 3 weeks before & after current week in graph

    Hi,

    Do i have to include the file name in the Series Values?

    ='Copy of dynamic_rang_(chart).xlsx'!chartAC

    I tried not to put the name of file and i got error.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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