1
Country      January    February    March   April   May June    July
USA             34        34          45     34      23
China           45        56          34     23      12
Japan           34        54          23     23      24

How can I show the last 3 months in the chart every time I update the data. Considering that column "Country" is fixed. Any workaround or easy formula to use in my "data selection" when creating a chart.

Greth
  • 13
  • 2

1 Answers1

0

This should work perfectly.

1. Re-arramge the data

    Country    USA  China  Japan
    January    34    45     34
    February   34    56     54
    March      45    34     23
    April      34    23     23
    May        23    12     24

Like so, it will be easier to work with. Here we assume the data starts at cell A1.

2. Create names in Name Manager (ctr+F3 to open)

    name:      refers to:

    months     =OFFSET(Sheet1!$A$1,COUNTA(Sheet1!$A:$A)-1,0,-MIN(length,COUNTA(Sheet1!$A:$A)-1),1)
    length     3
    usa        =OFFSET(months,0,1)
    china      =OFFSET(months,0,2)
    japan      =OFFSET(months,0,3)

In length, you note the desired time-period you wish to show (in your case 3 months); this can also be done with a cell reference and a COUNTA if you wish to make it dynamic and account for all the new data.

3. Create the chart

  • Click on blank cell and open the desired chart (I have done it with a 2-D Clustered Column). //Note that the chart should be blank.
  • Right-click on Select Data and click Add for Legend Entries (Series). Here for Series Name, select whatever is desired (in your case USA China Japan). For Series Value add =Sheet1!usa
  • Do this two more times for =Sheet1!china & =Sheet1!japan
  • Finally for the Axis Label add =Sheet1!months

Click though OK and you should be all set!

Make sure you check out how the offset function works here: https://support.office.com/en-za/article/OFFSET-function-c8de19ae-dd79-4b9b-a14e-b4d906d11b66

Newskooler
  • 3,973
  • 7
  • 46
  • 84
  • Hi,Stelian. I have done this workaround but I got a very large set of data (I got 25 countries). Would it possible without arranging it differently as presented in your #1. – Greth Jul 14 '15 at 13:22
  • Hi Greth, the formula should work either way. Ignore step 1 and you're good to go. – Newskooler Jul 14 '15 at 13:41
  • Hi, do you have an email add? I hope you could help me out with my file. – Greth Jul 14 '15 at 13:59
  • I do, but it does not show up. Anyway, here it is: s.m.nenkov@gmail.com – Newskooler Jul 14 '15 at 14:07