Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sumif value is in year

I have list of dates and values:

01.01.2016   100

01.02.2017   200

01.03.2017   300

What i want is now if the the year is 2017 count the value. Result: 200 + 300 = 500

This is a formula i tried:

=SUMIF($F5:$F,"<="&$A2,AF5:AF)

The issue is that google sheet can not compare a date and a year. When i change the date from 01.02.2017 to 2017 it works.

If i try to get the year of the date it doesnt work:

=SUMIF(YEAR($F5:$F),"="&$A2,AF5:AF)

How can compare a date with a year? Or is there an other way?

Thanks!

like image 764
Taaut Avatar asked Jun 16 '17 09:06

Taaut


People also ask

How do I Sumif an exact date?

SUMIF for the exact date You have two choices: 1) You can use a formula with the cell address. 2) You can write the date right into the formula. The date must be in the quotation marks.

How do I extract year from date in Excel?

Excel YEAR function=YEAR(A2) - returns the year of a date in cell A2. =YEAR("20-May-2015") - returns the year of the specified date.


1 Answers

Try this formula:

=SUM(FILTER(B:B,YEAR(A:A)=2017))

And also please try this:

=QUERY(A:B,"select year(A), sum(B) where A is not null group by year(A)")

enter image description here

like image 179
Max Makhrov Avatar answered Nov 02 '22 04:11

Max Makhrov