Excel (Google Spreadsheet): get values between two dates - excel-formula

I have seen lots of questions regarding this, on here and on other websites. However even with all that I have read I cannot accomplish what I want.
I have an Excel document with in cell A2 a starting date and in B2 an end date.
In A5:C11 I have a table with data. In cells A5:A11 I have dates, in B5:C11 I have the data. Now I want to display the data from B and C if they fall between the dates given in cells A2 and B2. I want to do so via a formula. I have tried many formulas with index, match, vlookup, small , sumproduct, if(s) and so on. Maybe any of you can help me?
Start date End date
29-12-2017 29-12-2017
Date Users Pageviews
04-01-2018 350 400
03-01-2018 300 350
02-01-2018 250 300
01-01-2018 200 250
31-12-2017 150 200
30-12-2017 100 150
29-12-2017 50 100
In this case I want the output to be, preferably in 3 cells:
29-12-2017 50 100

Make another table in F5:G11 with this formula in F5 and copy over:
=IF(AND($A5>=$A$2,$A5<=$B$2),B5,"")
Then in H5:I11 use this formula to remove the blank rows (adapted from here):
=IFERROR(INDEX(F$5:F$11,AGGREGATE(15,6,(ROW(F$5:F$11)-ROW(F$5)+1)/(F$5:F$11<>""),ROWS(G$5:G5))),"")
The result:
Parameter to change in green, your data in blue, intermediate formulae in grey (hide these columns?) and the final result in orange.

To get the list of dates use:
=IFERROR(AGGREGATE(15,6,$A$5:$A$11/(($A$5:$A$11>=$A$2)*($A$5:$A$11<=$B$2)),ROW(1:1)),"")
Then once we have the dates it is a simple Vlookup for the other two:
=IF(F5<>"",VLOOKUP($F5,$A$4:$C$11,COLUMN(B:B),FALSE),"")
Put the First in F5 and copy down.
Put the Second in G5 and copy over one column and down.

Related

duplicate multiple numbers in excel

I am trying to create a database in excel. I have a chronological list of 365 dates and I want to be able to fill in 100 cells for each date in a single row.
DATE
1/1/2018 (listed 100 times)
1/2/2018 (listed 100 times)
1/3/2018 (listed 100 times)
(1,36500)
In A1:
=DATE(2018,1,1) + FLOOR((ROW()-1)/100,1)
fill down to required point
You just highlight the first cell in the row, Cut and then select the next 100 cells and paste it in.

Excel countif(s) multiples

I'm trying to calculate the count of multiple occurrences of a figure using countif.
I have the range set but I need a calculation which can count in multiples of 50 without me having to type thousands of versions of countif (=COUNTIF(B2:B5,">=50")-COUNTIF(B2:B5,">100" etc.).
Data Count
50 1
70 1
80 1
10 0
150 3
This data should show 6 but at the moment I'm getting 4.
First you can start by making bins. you can make it with Data analysis tool or half manual
Like in the example, on A2 enter 0 and on b2 enter =a2+50
Same goes for a3 enter =b2 and last on a4 =a3+50
Now you can drag it down as much as you like.
Instaed of using countif use sumif finction. let's assume your data is on cloumn H and the values you want to sum are in column I, then on c2 enter
=SUMIFS(I:I,H:H,">"&A2,H:H,"<="&B2)
you can drag it down as much as you like.
Simply use Excels ROUNDDOWN function:
e.g. for B2: =ROUNDDOWN(A2/50,0)

Formula to count Text and dates by multiple criteria

I have been trying to create a formula that will count the number of occurrences based on multiple criteria. In the display below I am looking to populate cell C5 with the number of rows that meet a given criteria. In this case, when the start date is between C1 and C2 and the team is Green or Blue or the Department is WAZ. I have been able to get counts to work based on just the date or just the team but have been unable to find a solution with all 3.
Countifs is what I have been trying but without success. I can only get a portion of the criteria to work. As soon as I add in the date part it errors out.
Start 12/21/14 12/28/14 1/4/15
end 12/27/14 1/3/15 1/10/15
Project ID start date end date team Department
1 1/7/15 6/26/15 Blue SRT
2 12/27/14 1/23/18 Green DFT
3 1/8/15 3/20/15 Red DFT
4 1/3/15 6/20/15 Red WAZ
5 12/29/14 7/12/15 Blue DFT
Supposing that you have the following criteria:
J5 = red
J6 = DFT
and your are looking for dates (start & end) in C1 and C2.
I am using my example, please follow the data in the image below:
so put this formula in cell C3, which shows the number of rows for your query:
=COUNTIFS($C$5:$C$11,">="&C1,$D$5:$D$11,"<="&C2,E5:E11,J5,F5:F11,J6)
as you see the formula yields 2 because there are only two rows that match these conditions. (the rows are in bold, rows 6 and 7).
So basically a countifs can contain several criteria:
COUNTIFS(criteria_range1, criteria1, criteria_range2, criteria2, criteria_range3, criteria3 ...)

Automatically working out the average of filtered results

I have a spreadsheet where column P has a score between 1-6
The cell O4 has the following formula: =AVERAGEIFS(P8:P5000,P8:P5000,"<>6",P8:P5000,"<>0")
This formula searches for the average of the score in column P excluding 6, blanks and 0
Column O has staff names e.g John, Mark, Tim.......
What i want to do is for Cell O4 to automatically calculate the average of the figures shown in column P after i have used the filter function to show only results of a selected staff member.
I was hoping excel might be able to do this automatically however cell O4 appears to still be showing the average of the whole column P regardless of whether i have filtered or not.
I was given the formula below on another forum but it seems to be giving slightly wrong results albeit only by a small amount but i need to have the results exact if possible. Any help appreciated.
=SUMPRODUCT(1-ISNUMBER(MATCH(P8:P100,{0,6},0)),SUBTOTAL(9,OFFSET(P8,ROW(P8:P100)-ROW(P8),0,1)))/SUMPRODUCT(1-ISNUMBER(MATCH(P8:P100,{0,6},0)),SUBTOTAL(2,OFFSET(P8,ROW(P8:P100)-ROW(P8),0,1)))
Maybe
{=AVERAGE(IF((P8:P5000<>6)*(P8:P5000<>0)*SUBTOTAL(103,INDIRECT("O"&ROW(8:5000))),P8:P5000))}
will do what you want. Assuming the Filter is on column O.
The 103 in SUBTOTAL will also exclude if rows are manually hidden. If this ist unwanted and it should only exclude hidden rows, if filtered, then use 3 instead.
This is an array formula. Input it into the cell without the curly brackets and then press [Ctrl]+[Shift]+[Enter] to create the array formula.
I would create a separate table in a new sheet with all unique staff members and then perform the calculation. This way, you can quickly compare values for all staff just by scanning the table instead of having to constantly update the filter to see the values for potentially dozens or hundreds of staff. You would add the staff name range and criteria to your AVERAGEIFS formula.
For your example:
Sheet 2
A B
--- ---
1 | Staff Average
2 | Bob =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A2,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")
3 | Mary =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A3,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")
4 | Joe =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A4,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")

Excel spreadsheed populate cell based on value of another cell

I have a excel spreadsheet that contains a bunch of columns. My first column contains values of mpg(about 300 entries of miles per gallon). What I want to do is populate another column
based on whether the value of the first cell is greater than or less than 23.5
So basically it looks like this:
**A** **B**
10
15
29
14
32
24
I want column B to be populated depending on if the corresponding cell (eg. A1 > 24.5 so populate B with yes) is greater than 24.5 with yes or no.
Is there a simple function I can use to do it on all the values?
Please do provide detailed instructions since I hardly use excel and I'm lost on this past.
Type =IF(A2 > 23.5,"yes","no") into B2. Then double-click the bottom-right corner of the cell (the little box) to fill the rest of the cells.

Resources