Excel COUNTIF "Column D" year equals 2015 and Column L equals "15 or greater" - excel

I am able to count how many cells there are in Column D with year 2015. And I am able to count how many cells there are in Column L that are 15 or greater. However, I'm looking to combine these two formulas but I don't know how.
The formula I use to count the years is:
=SUMPRODUCT(--(TEXT('Sheet1'!D:D,"YYYY")="2015"))
The formula for counting 15 or greater is:
=COUNTIF('Sheet1'!L:L,">=15")
Can someone please provide a way I can combine these two formulas so I can count how many instances there was 15 or greater for the year 2015?
Thanks

COUNTIFS() with an S allows the ability of multiple criteria and you can bracket the dates:
=COUNTIFS('Sheet1'!L:L,">=15",'Sheet1'!D:D, ">=" & DATE(2015,1,1),'Sheet1'!D:D, "<=" & DATE(2015,12,31))
If your dates are actually text strings that look like dates you can do:
=COUNTIFS('Sheet1'!L:L,">=15",'Sheet1'!D:D,"*2015*")

Related

Excel - counting how many consecutive 0s in a row

I have multiple ‘people’ in rows in excel, with 10+ columns of system usage data. I want the final column to show how many consecutive months have 0 usage. For example, person a might have had 0 usage in March and April, used in June, then 0 usage in July - December, I would need the end column to show 6.
If your data is from B2 to M2 you could use the following formula:
=MAX(FREQUENCY(IF(B2:M2=0,COLUMN(B2:M2)),IF(B2:M2<>0,COLUMN(B2:M2))))
This will show the max number of consecutive 0's in that row 2 from column B to M.
Older versions of Excel require this array formula entered with ctrl+shift+enter
If you want the formula to show the quantity of consecutive zeroes of the last occurance in the row then you could use:
=LOOKUP(2,1/(FREQUENCY(IF($B2:$M2=0,COLUMN($B2:$M2)),IF($B2:$M2<>0,COLUMN($B2:$M2)))>0),FREQUENCY(IF($B2:$M2=0,COLUMN($B2:$M2)),IF($B2:$M2<>0,COLUMN($B2:$M2))))
I've made something for you, based on the numbers of the months in the year: 1-12 (in column "item").
In the "Value" column, there are the values zero or else.
The "Length" column contains the number of subsequent zeroes, based on following formulas:
First entry : =IF(B2=0,1,0)
Following entries: =IF(B3=0,C2+1,0)
Screenshot:
Have fun!
This might help if 2 is threshold for consecutive in F3:AI3
=SUM((FREQUENCY(IF(F3:AI3>=0,COLUMN(F3:AI3)),IF(F3:AI3<0,COLUMN(F3:AI3)))>=2)*1)
suppose I want count of values more than 10 in groups of 5 and more then
=SUM((FREQUENCY(IF(F3:AI3>=10,COLUMN(F3:AI3)),IF(F3:AI3<10,COLUMN(F3:AI3)))>=5)*1)
hope this helps

COUNTIFS for dates within last 12 months

I'm trying to count the number of dates in a range that fall within the last 12 months. The formula I have now counts YTD. Anyone know how i can adjust the formula to count the last 12 months?
=COUNTIFS(O19:O500,"*",L19:L500,B7,P19:P500,">43831")
Both of the following formulas work:
=COUNTIFS(O19:O500,"*",L19:L500,B7,P19:P500,">" & Today()-365))
=COUNTIFS(O19:O500,"*",L19:L500,B7,P19:P500,">" & edate(today(),-12))

Dynamic starting point of OFFSET and SUM formula

I have the following Excel spreadsheet:
A B C D E F G
1 Year 2015 2016 2017 2018 2019 2020
2 Revenue 5.000 4.000 6.000
3 Years to go back: 2
4 Sum of Periods: 10.000
In Row 1 you can find the years 2015 til 2020 and in Row 2 the corresponding revenue of each year.
In Cell C3 the user should input the number of years to go back and sum up the revenues. For example if the user puts in a 2 Excel goes back 2 years and sums up the revenue of 2017 and 2016 which is 10.000 in the case above. For this I used the following formula:
=SUM(OFFSET($E$2,0,-C3):$E$2)
This formula and the described calculation above work perfectly so far.
However, in 2018 I will have to adjust the starting point of Cell $E$2 in the formula above to Cell $F$2. Ohterwise the year 2018 will be excluded from the calculation.
=SUM(OFFSET($F$2,0,-C3):$F$2)
My question is now how can I avoid this permanent re-adjustment every year?
--> I think the solution should be a formula that identifies the first "non empty" cell within in a Row and then starts counting back the years from this cell. Somehow a combination of the SUM, OFFSET, ROW & COLUMN formula.
You may use this formula:
=SUM(INDIRECT("R2C" & (MATCH(YEAR(TODAY()),$1:$1,0) - $C$3 + 1) & ":R2C" & MATCH(YEAR(TODAY()),$1:$1,0), FALSE))
But be aware I'm assume the current year - $C$3 is within your data range.
Brief explain:
YEAR(TODAY()) - it will return the year of current date, then you don't need to re-adjust every year
MATCH(lookup_value, lookup_array, match_type) - it will find the value matched in first row, and return the index of cell
INDIRECT() - Form the result of match to a R1C1 notation, and convert the text to excel range
A simpler formula could be to use the 4th parameter of OFFSET to set the width and to calculate the starting point of the OFFSET using YEAR(TODAY()0-2016
=SUM(OFFSET($B$2,0,YEAR(TODAY())-$C$1,1,$B$3))
NON VOLATILE OPTION
Well non volatile if it were not for the TODAY() function. Replace TODAY() with a cell containing the starting year as a date. or replace Year(Today()) with a cell reference just containing the year (integer) and then it will be a non volatile option.
=SUM(INDEX($1:$1,MATCH(YEAR(TODAY()),$1:$1,0)):INDEX($1:$1,MATCH(YEAR(TODAY()),$1:$1,0)-($C$3-1))
Volatile functions recalculate every time something on the spreadsheet changes.
Non volatile functions only recalculate when something affecting them changes.
The index function returns the cell address with in the range its looking. for a 2D range you need to give row and column reference. For a 1D range, you only need to give find the position within the range.
Match finds a value within a given range.

Formula's with year and weeknumber

I want to create a SUMIFS formula with a date criteria. The whole report is based on years and weeknumers and I like to keep it that way without converting these to dates. The data is set up as following:
Col A Col B Col C Col D
YEAR Weeknumber Turnover ColA & ColB
I want to create a MAT turnover number based on the report week and year. I tried to merge colums A & B to get YYYYWW but since the first 9 weeks are only one digit the formula does not work.
note Cel F1 contains the report year and Cel F2 contains the report week
The sumif formula is the folowing:
=SUMIFS(C:C;D:D;"<="&F1&F2;D:D;">="&(F1-1)&F2)
Anyone got any idea how I can make this work?
So your column D formula:
=--(A1&TEXT(B1,"00"))
Your other formula:
=SUMIFS(C:C,D:D,"<=" & --(F1 & TEXT(F2,"00")),D:D,">=" & --(F1-1 & TEXT(F2,"00")))
If you want to do it all with one formula then:
=SUM(IF(( --(F1 & TEXT(F2,"00"))>=--(A:A &TEXT(B:B,"00")))*( --(F1-1 & TEXT(F2,"00"))<=--(A:A &TEXT(B:B,"00"))),C:C))
This is an array formula and needs to be confirmed with Ctrl-Shift-Enter when leaving edit mode.
This is slow as it is written. It would be best if all the full column references were truncated to just the extreme absolute data limit. As in A:A to $A$1:$A$10000. This will speed up the array formula.

Count number of occurences per day, months, quarter with Excel

From a list of sales (colmuns A and B), how can I extract the number of sales per day, months, quarter with Excel ? (ie columns D, F, H)
I found some dirty code solution with
=SUM(DECALER(...; (LINE()-2)*31; 0; 31; 1))
(sorry I don't know english's translation for Excel's DECALER function)
but it would very annoying to have to distinguish between months of 30, 31, 28 days, etc.
Do you know a clean solution ?
You can use this formula to count for each month:
=SUMPRODUCT((MONTH($A$1:$A$10)=2)*(YEAR($A$1:$A$10)=2013))
And this for quarters:
=SUMPRODUCT((MONTH($A$1:$A$10)>=1)*(MONTH($A$1:$A$10)<=3)*(YEAR($A$1:$A$10)=2013))
I assume dates in A1:A10, the quarter example is for first quarter, for second replace 1 by 4 and 3 by 6
Pivot Tables are the easy answer to this.
But you could inesrt 2 columns after the date
and use this forumula to get the month name
=TEXT(A2,"mmm")
In the other column use this formula to get the Quarter
=ROUNDUP(MONTH(A2)/3,0)
Then you can use COUNTIF or SUMIF depening on what you need to get your totals
Thanks to the two proposed answers given by StevenMartin and CRondao, here is what might be the simplest solution :
= COUNTIFS($A:$A; ">=" & C2;$A:$A; "<" & C3 )
This can be copied in all cells of column D and F (and also cells of H, provided I replace Q3, Q4 quarter names by the date of the beginning of each quarter).

Resources