Using month qualification in SUMIFS statment - excel

Here's what I'm looking for....
Trying to Sum the count of worksheet 'Results 2013' column G items
IF Cell A matches "Canada"
IF Cell E (date) is July
Having trouble with the date portion of the SUMIFS statement below.
SUMIFS('Results 2013'!$G$2:$G$510,'Results 2013'!$A2:$A$510
,"=Canada",'Results 2013'!$E2:$E510,MONTH('Results 2013'!$E2:$E510)=7)
Example value of "Results 2013"$E$480 is
I try this formula, and it provides back "January" which is obviously incorrect.
=TEXT(MONTH('Results 2013'!$E$480),"mmmm")
However, this formula, results in TRUE or 1
=IF(MONTH('Results 2013'!$E$480)=7,1,0)

The simplest solution is to add a column Month using the MONTH function to compute values, and then refer to this new column in SUMIFS.

This tests whether the date values in column E fall within the range 7/1/2013 and 7/31/2013. If your dates all fall within 2013, it will work.
SUMIFS('Results 2013'!$G$2:$G$510,'Results 2013'!$A2:$A$510,"=Canada",
'Results 2013'!$E2:$E510,">="&DATE(2013,7,1),
'Results 2013'!$E2:$E510,"<="&DATE(2013,7,31))
This array formula will work with the more general case of dates falling within any year:
=SUM(G2:G510*(A2:A510="Canada")*(MONTH(E2:E510)=7))

You could use an array formula , then you can use month on the entire column:
{SUM(if('Results 2013'!$A2:$A$510="Canada",1,0)*if(MONTH('Results 2013'!$E2:$E510)=7,'Results 2013'!$G$2:$G$510,0))}
just remember to use ctrl+shift+enter rather than the usual enter to finish the formula

Related

Check if date between date range in excel where there are multiple date ranges in a list and output corresponding range label

How can I check if an input_date falls between two dates (a date range) in excel, where the date range exists in a list of date ranges?
So I need to check if input_date falls between any date range, and then if it does, return the value of the date ranged it matched with. See the below table for an example.
Month
Start Date
End Date
Month 1
1/1/2022
1/31/2022
Month 2
2/1/2022
2/27/2022
Month 3
3/1/2022
3/31/2022
Input vs Expected Result
input_date
Expected Result = Month
1/25/2022
Month 1
2/3/2022
Month 2
I've tried using =IF(AND(A2>StartDate,A2<EndDate),TRUE, FALSE) but how can I check A2 against all date ranges in a list, and output the corresponding Month value? Is the best way really just nesting if statements for a fixed number of ranges? Any dynamic approach?
You may try using the either of formulas like shown below,
• Formula used in cell B7
=XLOOKUP(1,(A7>=$B$2:$B$4)*(A7<=$C$2:$C$4),$A$2:$A$4,"")
If one do not have access to XLOOKUP() then INDEX() & MATCH() can also be used,
• Formula used in cell C7
=INDEX($A$2:$A$4,MATCH(1,(A7>=$B$2:$B$4)*(A7<=$C$2:$C$4),0))
If you just require the text output of the month the input date is referring to then can you not just:
=TEXT(A2,"mmmm")
Or do you have a need for something outside of your example?
You can use the FILTER function to return the appropriate item from the "Month" column
If your Date Ranges are in a table named dateRange & the Input_Dateis inG2`:
=FILTER(dateRange[Month],(G2>=dateRange[Start Date]) * (G2<=dateRange[End Date]))

Vlookup with specific date showing N/A

I am trying to apply vllokup for a specific month of a specific year. My formula works for string lookup value but not works for date. here I attached my effort
First of all VLOOKUP() will not work in this case because VLOOKUP() always lookup values on first column of table then return value from corresponding row from specified column. So, you first column is strings and vlookup do not find dates on first column. Use Index/Match instead.
=INDEX(B3:B5,MATCH(D1,C3:C5,0))
You can also use FILTER() function.
=FILTER(B3:B5,C3:C5=D1)
Query() will also work-
=QUERY(B3:C,"select B where C= date '" & text(D1,"yyyy-mm-dd") & "'")
Vlookup works by searching columns to the left of the searched column. So you should modify your sheet to look like this (if possible) :
However, you should also take into account that the formatting of your cells could be misleading. If your D4cell has the value 1/Jan/2022 and your C6 cell has the value of 2/Jan/2022, then both of them will show as Jan 2022, but your formula will still return N/A because the real values of the cells are different.

How to count unique text values in a range, with some constraints given?

For example, I have a range cells:
Date Number
04/1/2019 A1
07/1/2019 A2
14/1/2019 -
15/1/2019 A1
02/2/2019 A3
07/2/2019 A1
and I want to count the amount of unique number in January, which is 2. What should I do? I am using anolder version of Excel, whcich does not support functions such as FILTER() and UNIQUE().
I have found a formula online:
{=SUM(IF(FREQUENCY(IF(data<>"", MATCH(data,data,0)),ROW(data)-ROW(data.firstcell)+1),1))}
which can count unique text values in a range which ignoring blank cells. However, I was unable to modify it to suit my usage, since it doesn't allow me to insert any criteria (such as date and ignore "-"). Most of the solution online involves functions such as FILTER() and UNIQUE(), which I am not able to use.
Slight modification of your attempt in D1, based on this handy website:
=SUM(--(FREQUENCY(IF((B2:B7<>"-")*(MONTH(A2:A7)=1),MATCH(B2:B7,B2:B7,0)),ROW(B2:B7)-ROW(B2)+1)>0))
Entered as array formula through CtrlShiftEnter
This boolean logic allows you to enter many more criteria if needed, such as YEAR if your dates can span more than the year 2019 and you need to filter on that too. Or include a check against empty values. It's very versatile.

Excel Formula to Calculate Text within a date range

I am trying to calculate values within a specific date range. The data I want to split between each month and the values: Successful, Incomplete and Failed.
I've tried pivot tables with this data but it doesn't work for me, also lacking pivot table excel experience. Formulas I'm more comfortable with.
I am using the following statement to at least get the total number of a value I add into it;
=COUNTIF('Jan 19'!$C$2:$C$1159,"Value")
Ex. If I put into the value "Successful" I get the total number of successful records.
I am looking into having a formula that I can input a specific month/date range (Jan, Feb, etc) and a value to get a count.
Ex. =Formula ((RangeOfData, "Value") AND (RangeOfData, (FromDate, ToDate))
I expect to the get the total number of a value(s) within a specific date range. If there isn't any data then the results would be blank or 0.
I'd use the formula COUNTIFS() as #cybernetic.nomad pointed in the comments so you can put more conditions on the COUNT:
=+COUNTIFS('Jan 19'!$B$2:$B$1159,">="&F3,'Jan 19'!$B$2:$B$1159,"<"&G3,'Jan 19'!$C$2:$C$1159,H3)
In the formula above I guessed the dates are in the COLUMN B, if not, you need to change it in the formula above.
To do that we should put the range we want to look at in a couple of cells where you would put the date range, in the example above:
F3 is the start date (if you want February of this year should be 1/2/2019).
G3 is the final date (if you want February of this year should be 1/3/2019).
H3 is where you can write "value", "successful" or any other string you are trying to count.

Microsoft Excel Array Formula with dates

I need the following array for a Date type:
=IF(OR(A2:C2="Mar 12"),1,0)
Sample Data
https://docs.google.com/spreadsheet/ccc?key=0AhoDU0OTM87sdHR3RGw3NTJacEV1OEt5OWZTWTBYUFE&usp=sharing
Looking at the sample data, in Column E I want an array formula that would look into columns B to D and search for results that contain 'May 12' and display true or false (1 or 0) in column E.
I think this will meet your needs - type in D2:
=IF(SUM((MONTH(A2:C2)=5)*(YEAR(A2:C2)=2013))>0,1,0)
but press CTRL+SHIFT+ENTER instead of usual ENTER - this will define an ARRAY formula and will result in {} brackets around it (but do NOT type them manually!).
Specify month and year as you wish)
I think this is what you're looking for (noticed the date format was dd/mm/yyyy so I adjusted):
=IF(COUNTIF(A1:C1,"12/5/2013")>0,TRUE,FALSE)
Edit:
For just month and day:
=IF(SUMPRODUCT((MONTH(A1:C1)=5)*(DAY(A1:C1)=12))>0,TRUE,FALSE)
Month and year:
=IF(SUMPRODUCT((MONTH(A1:C1)=5)*(YEAR(A1:C1)=2012))>0,TRUE,FALSE)

Resources