Use only Month and Year from date as criteria in countifs? - excel

I have an excel countifs formula with multiple criteria:
=COUNTIFS('Opp Data'!$E:$E,Home!$B11,'Opp Data'!$B:$B,Home!$D11)
My dates appear in column B on my Sheet OPP Data like so:
28/03/2016
21/04/2016
My lookup value in D11, D12 etc, will appear like so:
March - 2016
April - 2016
The dates will always be formatted like this.
Is there a way i can amend my countifs formula so that it recognises the month and the year as shown above from the dates in column B on my Opp Data sheet?
I have tried to get started by working on something like the below, but this doesn't work:
=COUNTIFS('Opp Data'!$E:$E,Home!$B11,TEXT('Opp Data'!$B:$B,"mmmm"),Home!$D11)
Please could someone show me where i am going wrong?
Thanks in advance

If you are willing to make your lookup table actual dates, you can use the SUMPRODUCT formula to get what you are after.
I have demonstrated in the below screenshot
Formula in F1: =SUMPRODUCT(--($A$1:$A$4=D1)*--(YEAR($B$1:$B$4)=YEAR(E1))*--(MONTH($B$1:$B$4)=MONTH(E1)))
If you really want to keep the text format you have, the following formula will work as in below screenshot:
Formula in I1: =SUMPRODUCT(--($A$1:$A$4=D1)*--(TEXT($B$1:$B$4,"YYYY")=RIGHT(H1,4))*--(TEXT($B$1:$B$4,"mmmm")=LEFT(H1,FIND("-",H1)-2)))

Related

Excel Formula - Making the concatenate cells showing a formula

Is there a way to show my Concatenate(SumIf formula resulting into a text cell that shows the formula of two cells.
So for example, I have:
Row 1: List of Dates.
Column A: I have the dates of clients months.
Column B: I have names
Column C: I have the totals
What I'm trying to do is showing what adding what, so in April it shows Willy twice, and so I want it to show: =C3(5751)+C9(8852)
What I have: https://i.stack.imgur.com/LMTAR.png
You may try below formula.
="="&TEXTJOIN("+",TRUE,FILTER(ADDRESS(ROW(C3:C10),3,4)&"("&C3:C10&")",(A3:A10=D1)*(B3:B10=D2)))
This one should work if I understood your question correctly:
="="&TEXTJOIN("+",TRUE,IF(A3&B3=A3:A25&B3:B25,"C"&ROW(C3:C25)&"("&C3:C25&")",""))
There's no reason to use sumif; as the result you want doesn't have the actual sum there.

Excel proper date format in Excel

I have worksheet named as Correlation_Process and it contains the field of Birthdate and Age.
what i want to do is to get the age based on the birthdate i already get the age based on the birthdate using excel formula. but some of the rows returns some error like this #VALUE!
Here's my excel formula to get the age: =DATEDIF(A:A,NOW(),"y")
and Here's my date format (Month/day/year) i dont get the error shown in picture which is #VALUE! when some of the rows are showing the expected output
anyone can help?
=DATEDIF(A:A,NOW(),"y")
The formula entered into cell B2 should be this:
=DATEDIF(A2, NOW(), "y")
Copy this formula down the B column and you should have the data you want.
The general formula for DATEDIF is
DATEDIF(first_date, second_date, UNIT)
Why dont you try something like this:
=TEXT(TODAY();"yyyy")-TEXT(A2;"yyyy")
And see if it works
OK lets go back to basics and the sure fired way to snag the date. We will rip apart the date manually and then recombine it.
Start by ripping apart the date into Day, Month and Year
Day
=MID(A2,4,2)
Month
=Left(A2,2)
Year
=Right(A2,4)
Now we will want to combine those values into the DATE(year,month,day) function.
=DATE(Right(A2,4),Left(A2,2),MID(A2,4,2))
Now you will want to use that in your DATEDIF formula
=DATEDIF(DATE(Right(A2,4),Left(A2,2),MID(A2,4,2)),NOW(),"y")
This assumes your dates are in the A column starting in ROW 2. Place the above formula in B2 and copy down. This is all based on your dates being text and not serial dates.

Match Excel Date Range with Day of Week

I have a expense form with a departure and return date. I would like to match all dates between the departure date and return, inclusive, to the day of the week and then populate that date under the appropriate day of the week that exists in another part of the form.
I've provided an example screenshot of what I'm trying to populate and what I'd like it to look like.
I've tried index/match, creating tables to allow the "in between" dates to expand automatically, linking to a date table in powerpivot, etc. and keep failing. I haven't tried an VBA yet.
Your thoughts are much appreciated!
There's plenty of ways to do this. Along similar lines to what you have tried, I got this. It works as per your screenshot and also tested with different dates below:
Formulas.
E1: =B1
E2: =E1+1 and drag down
F1: =IF(E1<=$B$2,TEXT(E1,"ddd"),"") and drag down
B12: =IFERROR(INDEX($E$1:$E$7,MATCH(B11,$F$1:$F$7,0)),"") and drag across

counting excel values by dynamic date

I have sheet like this:
The date spans across few months (but have constant number of entries, lets say there are 100 dates). That I'd like to do is to sum values for month and year, that are entered in B1 and B2 cells. I wanted to use SUMIFS, and use cell reference like this:
SUMIFS(B5:B1005;A5:A1005;">DATE(B1;B2;1)";A5:A1005;"<DATE(B1;B2+1;1)")
But I got 0 as result. And don't look that year is 2016 while dates are 2015- it doesn't work with 2015 either. All examples I found use static criterion, not cell reference. Is it possible to archive such result using only functions?
if you would like a helper column, you could do it like this:
In C5 put
=IF(AND(MONTH(A5)=$B$2,YEAR(A5)=$B$1),1,0)
and drag down.
In the Sum field you would then simply put
=SUMIF(C5:C1005,1,B5:B1005)
If you are using a Non-English Excel, then replace the : with ;.

Attempting to count cells in Excel using multiple criteria

As the title states, I am trying to count across cell ranges on a separate sheet but cant seem to get it to work. Any help would be greatly appreciated.
=COUNTIFS(MONTH(original!A2:A58),"1",original!D2:D58,"=East")
The issue is the Month() part in your formula. I understand your logic, but you'll have to probably add a new column on the Original sheet that has the month formula conversion there, then update the countif to reference it.
COUNTIFS(Original!monthcol, "1", Original!col, "East")
Again, in summary the Month formula can't do the conversion for an entire range of cells in the CountIf. The only other way would require an array formula. Hope this helps.
You cannot use the MONTH function as a form of sub-function in a COUNTIFS function. You need to add an extra level of calculation with something like a SUMPRODUCT function.
=SUMPRODUCT((MONTH(original!A2:A58)=1)*(original!D2:D58="East"))
That should count the instances where the month of the date in the Original worksheet's column A is January and the corresponding row's column D is East.
If you prefer to stay with a COUNTIFS and can keep the dates to a single year, you can provide a start date and end date which will bracket the month of January for a particular year.
=COUNTIFS(Original!A2:A58,">="&DATE(2015,1,1),Original!A2:A58,"<"&DATE(2015,2,1),Original!D2:D58,"East")
The default comparison operator for COUNTIFS is equals. There is no need to type it in.

Resources