Excel Averageifs with date criteria - excel-formula

I have 2 sheets called sheet1 and the other sheet2.
Info found on sheet1
Using columns a-d
Date Product qty used actual qty used
1-jan-16 aaaa 102 50
8-jan-16 aaaa 102 150
Date = 1 jan + 8 day till dec 31
sheet2 info
using columns a-d
Month count average
Jan
Feb
Mar
The count columns uses the =count function works OK.
But the average gives an error.
This is what I'm trying to do is average out the actual column on sheet 1 using the month criteria on sheet2, so for the month Jan it looks at sheet1 and averages out the 4 week that have the month Jan found in it.
I get #DIV/0! error
=AVERAGEIFS('sheet1'!H157:H208,'sheet1'!B157:B208,">="&Sheet2!A4,'sheet1'!B157:B208,"<="&EOMONTH(Sheet2!A4,0))
If any info missing please feel free to ask.
Thanks

For some reason it doesn't AVERAGEIFS does not like cell referencing against date values (at least for multiple conditions).
Provided that the Months are entered as actual month values formatted as mmm (which I assume based on the formula you provided), this formula works (I tested it against your sample data (extrapolated)):
=AVERAGEIFS('sheet1'!H157:H208,'sheet1'!B157:B208,">="&Date(YEAR(A4),MONTH(A4),1),'sheet1'!B157:B208,"<"&DATE(YEAR(A4),MONTH(A4)+1,1))

Related

Excel count if date range is active in a certain month

I have 2 date, a start date and end date. I want to be able to count if these were active through a certain month.
Row 1: start date 20/11/2020, end date 03/02/2021.
Row 2: start date 03/01/2021, end date 15/03/2021
Row 2: start date 12/01/2021, end date 31/03/2021,
The columns I have are the months and based on the above data this is the expected result.
Nov 1
Dec 1
Jan 3
Feb 3
Mar 2
Is there a formula that I can use to count this through a range of 100's of rows?
A simpler method than what you posted in your comment.
Put your start/end dates in a Table and name it StartEndTbl
Create a column of months whereby
Each entry is the first day of the month
The column is formatted mmm-yyy
In the first cell (F2 in this case), enter the formula:
F2: =SUM((StartEndTbl[Start]<=EOMONTH(E2,0))*(StartEndTbl[End]>=E2))
and fill down as far as needed

Copy Data from once cell to another cell based on conditions

I am facing an issue in excel in driving the formulas. I have data (Year, Salary, Name) in one sheet. It is updated vertically. In another sheet, I want to get list of salary for particular year. For 2019 there may be 4 rows for salary so I want all of them one by one. Below is the data:
Salary EMP Year
10000 a 2017
11500 b 2018
13000 c 2019
14500 d 2017
16000 f 2018
17500 s 2019
19000 g 2017
20500 h 2018
22000 h 2019
Output I require:
Year 2017 2018 2019
10000 11500 13000
14500 16000 17500
19000 20500 22000
So output should contain list of data for 2019 when I enter 2019 (all rows). there may be 50 rows in actual as I have given simple example of 8 rows only.
Kindly help me on this.
Thanks, Sharmil
I tried with pivot but it is giving total value rather than individual values. Also I tried with OFFSET, Index + Match function but it does not provide me correct output. Combination of OFFSET, Index + Match gives all rows for all single year.
Excuse me for the German language. SUMMEWENN is, indeed, SUMIF function. You can use a sumif Formula:
Sumif(Your criteria, Your search criterua, Your desired range to be summed)
Please see the below screenshot illustrating your example
Your criteria: Range C2 to C11
Your search criteria: B5 --> 2017
Your desired range to be summed: A2 to A11
Pivot Table is a possible solution but you will need a helper column to "rank" the Year.
Put the following formula in Cell D2 suppose your data range is A2:C13:
=COUNTIF($C$2:C2,C2)
Dray it down to apply across rows.
Then sort the data range by Year and then by Salary from Smallest to Largest.
Then insert a pivot table and layout the data as shown below.
The problem can also be solved by formula or power query but if a list like that is all you want I believe using Pivot Table is the most efficient way.
Let me know if you have any question. Cheers :)

How to collect number of days from a month in excel

I have a column which will have some days from a month in dd-mm-yyyy format. What I need to get total number of days from each month mentioned in that column. The column might not contain all days from each month.
Example :
Column A :
2017-01-01
2017-01-02
2017-01-17
2017-01-27
2017-02-08
In above example, from 2017 Jan, I have 4 days and from Feb I have one day. I need this count for a IF statement to run in C column. ie, in C1 there will be an IF function which will check the month in A1 and count the total number of days for that specific month from A column. If that count is below a specific digit, I need to perform a formula otherwise a different one. This will repeat for all C cell
If this column contains all date from each month I can use Day function to get total days, but here how Can I collect it
This will work: =SUMPRODUCT(1*(MONTH($A1:$A5)=D1))
And an example of manipulating basing on the result:
=IF(SUMPRODUCT(1*(MONTH($A1:$A5)=D1))<3;"good";"bad")
Another one when row number represents a month (JAN in C1, FEB in C2...):
=IF(SUMPRODUCT(1*(MONTH($A1:$A5)=ROW()))<3;"good";"bad")
In your case:
=IF(SUMPRODUCT(1*(MONTH($A1:$A5)=ROW()))<10;function1();function2())
Array formula - use Ctrl+Shift+Enter:
=SUM((MONTH($A$1:$A$5)=MONTH(A1))*(YEAR($A$1:$A$5)=YEAR(A1)))

add values for a range between reference date minus 6 days in excel

i would like to add the corresponding values of dates with reference to a particular date and -6 days in excel.
For example: reference date is 10th feb 15. I would like to add values under flight time column for dates ranging between 10th feb 15 and previous 6 days.
similarly add values for a reference date and previous 30 days values and 1 year values.
What i wanted was, sum all the flight timings of a particular date in column A. I used the sumifs formula to achieve this.
The formula is =SUMIFS($I$8:$I$1122,$A$8:$A$1122,"<="&C8,$A$8:$A$1122,">="&C8-6)
What it does: Here the reference cell is C8 which is 6th Feb 14
step 1- date range for the calculation is 6th feb 14 minus 6 days
step 2- add the values of column I which correspond to all the dates that fall within 6th feb 14 to 31st jan 14
step 3- indicate the sum in column K
Unfortunately i cannot include any pictures or files to show what i have mentioned due to site limitations.

Use date as a criteria in SUM or sumif function

I have two columns
Amount Date
100 01/01/2000
2000 01/12/2002
2000 02/02/2005
150 03/02/2000
250 05/03/2002
350 04/05/2006
I need result as follows
Total year
2005 - 2000
2000 - 250
2002 - 2250
2006 - 350
Can I use SUMIF function for this? If it's possible what criteria I have to put?
You can use the same formula as described in this thread: Summarize grouping by year and month
=SUMPRODUCT((YEAR(Sheet1!$B$2:$B$6)=A2)*Sheet1!$A$2:$A$6)
I supposed your data are in an array from A1 to A6 on Sheet1 and your results are on another Sheet, you put the year in column A and the formula in column B
If you add a column to the right of the date column containing
=year(B2)
(replace B2 with whichever cell contains the date in that row)
and fill that column down, then you can do a standard sumif on that column like
=sumif(C2:C10, 2002, A2:A10)

Resources