Use date as a criteria in SUM or sumif function - excel

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)

Related

If there a function to count a cell if it’s blank or non- blank based on if it’s located with in cellls in a date range?

Criteria I need my formula based on:
A
B
C
1
7/3/2021
2
7/5/2021
3
July 1,2021
775
4
July 2,2021
788
5
July 3,2021
73738
6
July 4,2021
73738
7
July 5,2021
73738
if the column c is blank or has a number in it (doesn’t matter what number)
if the cell c corresponds with cell b if it is in between the dates in B1 & B2
so essentially there would be 3 cells counted in this instance
What I am doing is in column B i’m entering in all the days in the month. Then in B1(admission date) B2 ( discharge date) , In c I will write a value .
I want the formula to count the cells(C:C) (both blank and non blank) between admission date and discharge date that the patient was admitted for .
The function below counts the number of entries between B1 and B2 whether they are blank or not.
=COUNTIFS(B3:B7,">="&B1,B3:B7,"<="&B2)
The formula will return 3 for your example. Your question doesn't clarify how blank cells affect this count but more conditions could be added to it.

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 :)

Sorting values of a selectable month

I have the following Excel spreadsheet:
A B C D E
1 January February March February
2 Product A 500 300 800 500
3 Product B 400 500 250 300
4 Product C 600 100 700 100
In Columns A:C you can see the sales of three different products.
In Column E the user can select a month in Cell E1.
Based on this month the sales should be listed ascending.
I think this requires something like a VLOOKUP combined with a LARGE function since the matrix from the LARGE function has to switch based on the month in Cell E1.
Do you have any idea how I could achieve this?
You could use HLOOKUP to locate the month in E1 in the range B1:D1, but this just gives the value of the month ("February") and you need the position of the month (from 1 to 3) to find the right column B,C or D so I suggest using Index and Match as follows
=IFERROR(LARGE(INDEX($B$2:$D$4,0,MATCH($E$1,$B$1:$D$1,0)),ROWS($1:1)),"")

Sum with dynamic condition

I have an Excel file in which some columns. The Excel is my bank account.
The D column is date, and not just for one day,its the days of a week.
I want to some all columns in that has the same date, and insert it in new cell.ex : for a week i should have 7 sum.
Here is some possible data from the sheet.
date(Column D) Money(Column K) Sum of same date(Column N)
1396/1/1 2300
1396/1/1 1000 3300 // some of the same date
1396/1/2 1200
1396/1/2 320 1550 // some of the same date
It is possible with Excel functions? Does I need a subroutin?
In L2 try,
=IF(ROW()=MATCH(D2, D:D), SUMIFS(K:K, D:D, D2), TEXT(,))
Fill down.
Use this formula:
=IF(D2<>D3,SUMIF(D:D,D2,K:K),"")
Then copy down
Hey you need to work with Sumif or SUMIFS and your Formula should like,
SUMIFS(D2:D10, C2:C10,">="&TODAY()-7, C2:C10,"<="&TODAY())
Or it should be like,
=SUMIFS(D2:D10, C2:C10,">="&A2, C2:C10,"<="&A3)
Or
=SUMIF(D2:D10, C2:C10,">="&TODAY())
NB: Sum Range is D2:D10 & C2:C10 is Criteria range.
In 2nd example A2 & A3 Cells holds Date value.
Suppose your Dates are in Col A & you want to Sum values in Column B, so instead of Sumif you can use this,
C2=SUMPRODUCT(--(MONTH(A$2:A$10)=ROW()-1),--(B$2:B$10))
NB: MONTH function will pull the Month value from A2 and add with corresponding Cell value in B, drag the formula below.

Excel Averageifs with date criteria

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))

Resources