I cannot find a way to do this, is it possible (with excel functions or VBS)?
For example, these would be the initial values:
Number
Value
101
234
102
324
103
345
104
325
105
437
106
443
107
806
108
476
109
538
110
546
And after taking the three highest numbers, this would be the output:
Number
Value
107
806
110
546
109
538
The data is constantly updating, so that might cause some issues.
You can use FILTER in combination with LARGE function to achieve this:
Columns A and B represent sample data. Cell D2 can contain this formula:
=FILTER($A$2:$B$9,$B$2:$B$9>=LARGE($B$2:$B$9,3))
If data is constantly updating, better to have an Excel Table (I named TB_NumVal), so the range index get automatically updated.
In cell: J2:
=SORT(FILTER(SORT(TB_NumVal,2), (ROW(TB_NumVal[Number])-1)
> ROWS(TB_NumVal[Number])-3),2,-1)
Here is the output:
Explanation
We sort the data, then since we start on row 2 (row 1 is the header) we substract 1. So
ROW(TB_NumVal[Number])-1
will provide the row number starting from one.
ROWS(TB_NumVal[Number])
is the total number of rows, in our case 10.
Using a filter condition like this:
(ROW(TB_NumVal[Number])-1) > ROWS(TB_NumVal[Number])-3)
ensures only the last three row will be selected, then finally sorted the filtered result by value in descending order to match the result of the screenshot of the question.
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))
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.
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
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: