Excel line graph do not show next weeks with na() - excel

I have an excel grid with a weekly graph.
The Value of the weekly graphs are all formulas and it looks like this:
19-Feb-15 314
26-Feb-15 319
5-Mar-15 356
12-Mar-15 #N/A
19-Mar-15 #N/A
26-Mar-15 #N/A
If I select the line graph's value up to 26 March then it gives me 3 gaps for 12 March, 19 March and 26 March. But I would like the graph to end on 5 March and not give me these gaps.
Then next week when I add a value on 12 March it will automatically add it to the line graph and show no gaps for 19 and 26 March.
I hope that's clear enough.
If the above is not doable, then maybe you have a VBA code which I could use so someone can simply click a button so it updates the graph with the data from the last 12 weeks.
Tks in advance.

If you are willing to create an extra column, assuming your data starts in column A then you can simple put this formula in column C:
=IF(ISERROR(B1),NA(),A1)
So your data would look like:
A B C
19-Feb-15 314 =IF(ISERROR(B1),NA(),A1)
26-Feb-15 319 =IF(ISERROR(B2),NA(),A2)
05-Mar-15 356 =IF(ISERROR(B3),NA(),A3)
12-Mar-15 #N/A =IF(ISERROR(B4),NA(),A4)
19-Mar-15 #N/A =IF(ISERROR(B5),NA(),A5)
26-Mar-15 #N/A =IF(ISERROR(B6),NA(),A6)
Which turns to:
A B C
19-Feb-15 314 19-Feb-15
26-Feb-15 319 26-Feb-15
05-Mar-15 356 05-Mar-15
12-Mar-15 #N/A #N/A
19-Mar-15 #N/A #N/A
26-Mar-15 #N/A #N/A
Then if you keep column B as your Y values but you now select column C as your X values the graph will automatically adjust as you enter data:

Related

Excel automatically charting for concrete range of data

Excel masters, I need help about charting in excel. I have a table with data ("WEEK number", "date of start", "some data") and chart! the problem is: I need when I add new week data the chart should automatically update but I need to see only 53 weeks. For example: if I add week 30 I need to see data on the chart from week 30 (2018) to week 30 (2019)
Thank you for your help in advance
Week # Start Date Data
20 05-13-2018 21,866
21 05-20-2018 20,317
22 05-27-2018 18,078
23 06-03-2018 19,254
24 06-10-2018 17,990
25 06-17-2018 19,589
26 06-24-2018 22,346
27 07-01-2018 18,985
28 07-08-2018 18,482
29 07-15-2018 17,493
30 07-22-2018 21,217
31 07-29-2018 16,205
32 08-05-2018 16,534
33 08-12-2018 16,694
34 08-19-2018 18,190
35 08-26-2018 20,559
36 09-02-2018 24,503
37 09-09-2018 26,074
38 09-16-2018 24,092
39 09-23-2018 33,828
40 09-30-2018 28,979
41 10-07-2018 28,493
42 10-14-2018 30,634
43 10-21-2018 29,473
44 10-28-2018 28,202
45 11-04-2018 30,088
46 11-11-2018 36,070
47 11-18-2018 36,689
48 11-25-2018 35,509
49 12-02-2018 27,794
50 12-09-2018 27,802
51 12-16-2018 16,521
52 12-23-2018 13,786
1 12-31-2018 18,271
2 01-07-2019 27,336
3 01-14-2019 29,837
4 01-21-2019 31,464
5 01-28-2019 31,395
6 02-04-2019 31,383
7 02-11-2019 28,152
8 02-18-2019 30,795
9 02-25-2019 25,183
10 03-04-2019 28,344
11 03-11-2019 38,064
12 03-18-2019 36,815
13 03-25-2019 36,741
14 04-01-2019 35,849
15 04-08-2019 35,199
16 04-15-2019 28,407
17 04-22-2019 16,427
18 04-29-2019 29,678
19 05-06-2019 28,270
20 05-13-2019 24,046
21 05-20-2019 21,191
22 05-27-2019 21,480
23 06-03-2019 23,919
24 06-10-2019 20,532
25 06-17-2019 20,575
26 06-24-2019 19,111
27 07-01-2019 19,279
28 07-08-2019 22,265
29 07-15-2019 5,979
You can use defined names to automatically update a chart range in Excel.
You can refer to any array/range by a name in excel. There are formulas to find the specific array/range and we call them Array Formulas. One of the most common array formula is OFFSET. If you are not familiar with this formula, please google some tutorials online before continue.
In your example, let's presume Week # is in Column A, Start Date is in Column B, and Data is in Column C, and the name of the worksheet is SheetName.
In order to dynamically look up a 53-Week range in Column A, B and C using OFFSET formula, you need to find the starting point (i.e. the cell in each column corresponds to the first week of the 53-week range) .
For instance, if your latest Week # is Week #29 in Cell A63, the starting point would be Week #29 in Cell A11. One way of finding the latest week # is to find the corresponding maximum/latest date in the Start Date column, and use MATCH formula to find the row number. Such logic is translated into the following formulas:
Start Point in Column A (the Week # column) ="A"&MATCH(MAX(B:B),B:B,0)-52
Start Point in Column B (the Start Date column) ="B"&MATCH(MAX(B:B),B:B,0)-52
Start Point in Column C (the Data column) ="C"&MATCH(MAX(B:B),B:B,0)-52
Then you can find the 53-Week range in each column by referencing the relevant starting point in the OFFSET formula. Please note you need to press CSE Ctrl+Shift+Enter upon finishing entering each array formula to make it work.
For Column A (the Week # column) =OFFSET(INDIRECT("SheetName!A"&MATCH(MAX(SheetName!$B:$B),SheetName!$B:$B,0)-52),,,53)
For Column B (the Start Date column) =OFFSET(INDIRECT("SheetName!B"&MATCH(MAX(SheetName!$B:$B),SheetName!$B:$B,0)-52),,,53)
For Column C (the Data column) =OFFSET(INDIRECT("SheetName!C"&MATCH(MAX(SheetName!$B:$B),SheetName!$B:$B,0)-52),,,53)
The next step is to create three names for the above ranges. Press Ctrl+F3 to open the Name Manager in excel, and manually create the names and copy and paste the above formulas in the 'Refers to:' field.
Then you can create a chart from the existing data, and replace the hard-coded series values with the range names to make it dynamic as shown below:
Click anywhere within the chart, then you will see the Chart Design tab shown on top of the the ribbon of your excel. Go to Select Data and Edit the Data and Date value as shown below:
I have created a sample bar chart below showing the data for the most recent 53 weeks. Please note I have added 5 weeks' of new data to test the result, and I have put the Week # as the data label for the bar chart instead of the actual dollar value.
Lastly, you can refer to the following article for more clarifications.
How to use defined names to automatically update a chart range in Excel

Summing every first month columns in Excel

I am trying to add the sum of the first 7 columns and then the next 7th columns etc in Excel. So for example if I have the below data and I needed to be added weekly,
Day 02/01/2017 03/01/2017 04/01/2017 05/01/2017 06/01/2017 07/01/2017 08/01/2017 09/01/2017 10/01/2017 11/01/2017 12/01/2017 13/01/2017 14/01/2017 15/01/2017
Presented Calls 1000 1550 900 1455 789 987 1435 1200 1675 1230 1232 1400 999 650
So if I want to add the presented calls from 02/01 - 07/01 this should be sum(B2:H2)
Then the sum of the presented calls from 08/01-15/01 this should be sum(I2:M2)
etc
However at the moment in Excel it is being sum(B2:H2) then sum(C2:I2) which is incorrect, can anyone help?
You can use the OFFSET() function combined with the COLUMN() function and a bit of arithmetic to get the desired range to sum.
Try entering this formula and fill across.
=SUM(OFFSET($B$2,0,(COLUMN()-COLUMN($B$2))*7,1,7))

Conditional formatting on the first x number of rows, regardless of filter or sort, in Excel

I'm trying to find a way to easily identify the first ten rows in a table column, no matter how it's been sorted/filtered. Is there a way to use conditional formatting to highlight these cells?
Examples of desired results...
Sample data:
product price units code
Item02 15.97 2191 7UQC
Item05 12.95 1523 TAAI
Item13 9.49 1410 LV9E
Item01 5.69 591 6DOY
Item04 15.97 554 ZCN2
Item08 10.68 451 2GN0
Item03 13.95 411 FP6A
Item07 25.45 174 PEWK
Item09 14.99 157 B5S4
Item06 18 152 XJ4G
Item10 11.45 148 BY8M
Item11 16.99 66 86C2
Item12 24.5 17 X31K
Item14 24.95 14 QJEI
When sorting by price the first 10 products highlighted differ from those in the next example.
The first 10 visible products are highlighted after filtering out Item12, Item05, and Item08.
Choosing to sort by units automatically highlights a different set of products.
Use this formula in the Conditional Formatting:
=SUBTOTAL(3,$A$2:$A2)<11
Make sure it applies to the entire dataset.
The formula returns the row number relative to the visible row number. Thus as a row is hidden the row beneath the hidden returns one greater than it would.
To see how it works place SUBTOTAL(3,$A$2:$A2) in an empty column. Then filter the table and watch as the numbers change.
The 3 refers to the COUNTA() function, which will count any non-empty cell.
Subtotal is designed to work with data that gets filtered to return only the visible data.
So the Formula will only count the visible cells that are not empty.
In the conditional formatting dialog, choose New rule -> Use a formula.... Enter =row()<=10.

Conditional averages (AVERAGEIF, AVERAGEIFS, or other option?)

Perhaps it's just been a long week, but I can't think of how to get a pretty simple average.
Here's my data (two columns):
1/3/1994 1165
1/4/1994 1162
1/5/1994 1133
1/6/1994 1133
1/7/1994 1138
1/10/1994 1143
1/11/1994 1118
1/12/1994 1150
1/13/1994 1171
1/14/1994 1177
1/17/1994 1161
1/18/1994 1162
1/19/1994 1121
1/20/1994 1112
1/21/1994 1129
1/24/1994 1136
1/25/1994 1124
1/26/1994 1118
1/27/1994 1127
1/28/1994 1133
1/31/1994 1088
2/1/1994 1055
2/2/1994 1051
2/3/1994 1071
2/4/1994 1079
2/7/1994 1054
2/8/1994 1079
2/9/1994 1079
2/10/1994 1089
2/11/1994 1074
2/14/1994 1083
2/15/1994 1068
2/16/1994 1075
2/17/1994 1071
As you can see, it's a column of dates (that continue until Sept. 9 2015, so it's long), and another of price. I am just trying to get the averages for January each month, of each year (i.e. Jan 1994, 1995, 1996 ... 2015, then Feb 1994, etc).
Here's the table I plan on using the formula in:
2007 2008 2009 2010 2011
January
February
March
April
So, in the cell right of "January" and below "2007", I want the average of prices that are in Jan, 2007.
I tried using this (again, my data starts in A1 and B1):
=AverageIfs(B:B,year(A:A),1994,month(A:A),1) (regular and as array), but it doesn't work - I keep getting the error "The formula you typed contains an error." (I'd really prefer this to be a formula, rather than a VB solution)
Thanks for any ideas!
Edit: In the mean time, I have created two helper columns, that are just the Month() and Year() of each row of data. Then I can use =AverageIfs(B:B,[month helper range],1,[year helper range],2007). Is there a way to do this without a helper column though?
Try this
=AVERAGE(IF(YEAR(A:A)=1994,IF(MONTH(A:A)=1,B:B,""),""))
entered as an array formula (CTRL-SHIFT-ENTER). If you want to use the month as text you could use
=AVERAGE(IF(YEAR(A:A)=1994,IF(TEXT(A:A,"mmmm")="January",B:B,""),""))
Hope that helps
assuming your data has a header: "Date" and "Price" in cells A1, B1.
assuming your data begins in A2 = "1/3/1994" and B2 = 1165
C1 = "Month"
D1 = "Year"
C2 = =TEXT(A2,"Mmmm")
D2 = =YEAR(A2)
Copy Cells C2+D2 down ...
I place your new table in:
H2 = "January"
H3 = "February"
... etc.
I1 = 1994
J1 = 1995
... etc.
I2 = =AVERAGEIFS($B:$B,$C:$C,$H2,$D:$D,I$1)
and copy that formula throughout the table.
Cheers!
Yes, you can use AVERAGEIFS() and you should. This is about a thousand times faster than the accepted answer:
=AVERAGEIFS(B:B,A:A,">="&DATE(1994,1,1),A:A,"<"&DATE(1994,2,1))
You can even do it this way for a more concise formula, but I believe it raises problems for non-USA users because of their date format settings:
=AVERAGEIFS(B:B,A:A,">=1/1/94",A:A,"<2/1/94")
I don't know if this is the most concise solution, but it works. You can use SUMPRODUCT as follows:
=SUMPRODUCT((MONTH($A:$A)=1)*(YEAR($A:$A)=1994)*$B:$B)/SUMPRODUCT((MONTH($A:$A)=1)*(YEAR($A:$A)=1994))
What this is essentially doing is summing the values in column B based on the two criteria, and then counting the number of rows that matched the criteria and dividing by that number.
For each row, the MONTH and YEAR conditions evaluate to either 1 (true) or 0 (false) and then those two values are multiplied with the value in column B, resulting in column B's value if both conditions are true, or 0 if one or both conditions are false.
This solution requires to use in the "table with the results" the number of the month instead of the names of the month
It also assumes that the "table with the results" starts at F2 (see picture)
Then use this formula:
=IFERROR(AVERAGEIFS($B:$B,$A:$A,">="&DATE(G$2,$F3,1),$A:$A,"<="&EOMONTH(DATE(Q$19,$P20,1),0)),"N/A")
The formula shows “N/A” if there are no prices for the period (Year/Month), if you want to see blank then replace it with “”
Small changes done to your sample data to work with several periods

SUMIF dynamically change summing column

I am using SUMIFS and want the sum_range dynamically to change according to the name I have of a column.
I have a table with about 100 columns. Say one of these columns is Paid_BC_items. I want a formula that looks for which column Paid_BC_items is in and somehow insert that into the SUMIF here where the Sheet4!J:J part is. I have a few other criteria here too which are fixed so they don't need to be dynamic.
=SUMIFS(Sheet4!J:J,Sheet4!$C:$C,Sheet2!$D$3,Sheet4!$E:$E, Sheet2!$C6, Sheet4!$G:$G, Sheet2!$D6)
If for example I changed the column heading to something else I want the SUMIF then to look for that column in the big tables and return that.
I know it has something to do with indexing, matching and indirects but I just can't figure it out right now.
Year Week Total Orders Paid_BC_items Free_BC_items
2014 1 971 147 104
2014 2 1565 339 213
2014 3 1289 391 209
2014 4 1171 389 228
2014 5 1163 375 240
2014 6 1298 405 330
2014 7 1233 404 292
Try using this in place of the sum range
INDEX(Sheet4!A:DZ,0,MATCH("Paid_BC_Items",A1:DZ1,0))
when you use INDEX with 0 as the row argument you get the whole column....and MATCH picks the right column based on the header
Whole formula becomes:
=SUMIFS(INDEX(Sheet4!A:DZ,0,MATCH("Paid_BC_Items",A1:DZ1,0)),Sheet4!$C:$C,Sheet2!$D$3,Sheet4!$E:$E, Sheet2!$C6, Sheet4!$G:$G, Sheet2!$D6)
to make dynamic & be able to drag across for all column headings
MATCH(indirect(d$1),A1:DZ1,0))

Resources