COUNTIFS with range criteria on different sheets - excel

I have not read if there is a limitation with COUNTIFS function, but I am experiencing the following:
I want to count the number the number of times two conditions are true in a row. For example
Sheet 1
USERID DATE
SAM 12/1/2014
SAM 12/3/2014
SAM 12/4/2014
JON 12/3/2014
BOB 11/5/2014
Sheet 2
Dates to match against {12/3/2014, 12/4/2014, 12/5/2014}
Sheet 3
USERID DATECount
SAM 2
JON 1
BOB 0
If all this information is in the same sheet the following formula works (Assuming data in Sheet 1 is in columns A and B, and the data in Sheet 2 is in the first row D to F, and the data in Sheet 3 starts at D5.
=COUNTIFS(A:A,D5,B:B,"="&$D$1:$F$1)
Currently, to get over this, I have a SUM function and a COUNTIFS for each criteria in the range for criteria 2. But it's pretty ugly since there are 20 criteria.
What I trying to find is a more elegant way to do this, or if there is another function that can return the same results.
Note that the date range can change every month.

You need a SUMPRODUCT wrapper that will iterate the COUNTIFS results through the cells in Sheet2!$D$1:$F$1.
      
The formula in Sheet3!E5 is,
=SUMPRODUCT(COUNTIFS(Sheet1!A:A,D5,Sheet1!B:B,Sheet2!$D$1:$F$1))
Fill down as necessary.

Related

Excel > Exclude a named range from COUNTIFS

I've got a spreadsheet with hundred of rows, each with a unique ID and each designated to a person.
On a different tab is a summary sheet where my formula goes (count of IDs for each person). On a third sheet, I have a named range 'excludes' which has certain IDs included in a single column.
i.e my sheet1 has:
ID Name
1 Bob
2 Bob
3 Bob
4 Shirley
5 Ted
6 Michael
The named range has say IDs, 2 and 3 in it, so I want my COUNTIFS to return the value 1 for Bob.
ID
2
3
Here's my formula but I think I'm missing something:
=COUNTIFS('Sheet1'!A:A,'summary'!$A1,'Sheet1!A:A,"<>excludes")
I want to exclude every ID in the excludes named range from my COUNTIFS result.
Do I need to use sumproduct or something?
Thanks for your help!
Use SUMPRODUCT:
=SUMPRODUCT((B2:B7=D2)*(ISERROR(MATCH(A2:A7,excludes,0))))
If you want countifs then you will need to count the whole and subtract where it exists in the named range:
=COUNTIFS(B:B,D2)-SUMPRODUCT(COUNTIFS(B:B,D2,A:A,excludes))

Vlookup and sum all instances of the matching lookup

this is probably an extremely basic problem but I can't figure a way to do this within Excel.
I have a list of values IDs from a regional sales manager,
he wants to see if his figures have been inputted into the monthly report and are reporting correctly.
However, as he sells by region and we report by product we have multiple instances of his ID by Product
so our monthly report.. for example
ID Value
1 16,999
1 22,521
3 400
3 221
5 71
6 22,000
So he has provided me with a list of IDs
1
2
3
4
5
6
and wants a list with its total revenue not just the first match up.
Is an excel limitation or is there a way to do this?
You can use a SUMIF formula. Basically you give it the column to check the value of, then you give it the expected value and finally the colum to sum.
Option 1 (whole range)
=SUMIF(A:A, 1, B:B)
Option 2 (defined range)
=SUMIF(A1:A7, 1, B1:B7)
Option 3 (Using excel table)
=SUMIF([Id], 1, [Value])
For more details please refer to: https://support.office.com/en-ie/article/sumif-function-169b8c99-c05c-4483-a712-1697a653039b
Is this what you're looking for?
=SUMPRODUCT((A1:A5=1)*B1:B5)
Taken from here: Sum values from multiple rows using vlookup or index/match functions
How it works:
An array formula is used to create an array of numbers that gets passed to the SUMPRODUCT formula.
The array formula processes A1 and B1 together, then A2 and B2 and so on... if A1 is equal to 1, B1 is added to the array.

Excel matching cell value and date range

i'm working on some data checking and faced problem to ease my checking. Hope anyone here can help me
I've two sheet of data
Sheet 1
John 01.10.2017 10.10.2017 A
Chloe 10.10.2017 10.10.2017 B
Jess 20.11.2017 22.11.2017 C
John 12.10.2017 13.10.2017 D
Sheet 2
Name Date Result
John 01.10.2017 A
John 11.10.2017 #N/A
Chloe 10.10.2017 B
I need a formula to cater on Sheet 2, result column.
If sheet 2 name with date fall/collision in btw sheet 1 date range, excel could help show the result
note that name on sheet 1 maybe repeated with different date range, but sheet 2 i wish to check the name whether conllision with sheet 1 data
Appreciate if anyone can help
First you need to format your dates properly. Format them as date times etc.
Then in the sheet 2 results column have a function something like this:
=IF(AND(A1=Sheet1!A1, B1>=Sheet1!B1, B1<=Sheet1!C1),TRUE,FALSE)
This will return TRUE for John for instance.
You then extend this for the rest of your cases.

Count with criteria for changing column in excel

I have a data looks like this:
a b c
1 3 4
2 3 3
4 1 2
2 4 2
In another worksheet, I want to do the following calculation:
whenever A1 returns a (header of data worksheet), count number of items that are smaller and equal to 2 in column "a". (result will be 2)
if A1 returns b, count number of items that are smaller and equal to 2 in column "b". (result will be 1).
A1 has already been preset with formula such that it will show a or b or c as conditions changed.
I need the formula to be lean... I actually have 6 headers, so if I keep on using if functions, I will probably have to set 6 if functions in one cell...that can be overwhelming. index match cannot provide a range to work on...Any suggestion? thanks
I don't know vba. If you could provide a workable vba code, i don't mind. but i don't know how to read it...>.< please provide user manual for that. lol, thank you~
If your data is found on Sheet1 and the a is found on column a, b is found on column b etc. enter this formula on then next sheet on b1 when a1 is the column value:
=COUNTIF(INDIRECT("Sheet1!"&a1&":"&a1),"<=2")
The Indirect is for adding text to your reference.
If your data sheet is Sheet1, you could try the array formula:-
=SUM((Sheet1!A1:C1=$A$1)*(Sheet1!A2:C5<=2))
Must be entered with CtrlShiftEnter
(actually there are 3 items less than or equal to 2 in column A)
Or you can use the SUMPRODUCT version if you prefer not to use an array formula:-
=SUMPRODUCT((Sheet1!A1:C1=$A$1)*(Sheet1!A2:C5<=2))
Or you can use this INDEX/MATCH method which is probably more efficient:-
=COUNTIF(INDEX(Sheet1!A2:C5,,MATCH(A1,Sheet1!A1:C1,0)),"<="&2)

Countif formula with multiple criteria

In my workbook, I have a 4 spreadsheets - Data, Amy, Betty, Connie. Data has the following columns:
Column A Column B Column C Column D
Row 3 Employee Total tasks last 30 days. Total tasks last 7 days. Date/Time Last task Assigned
Row 4 Amy
Row 5 Betty
Row 6 Connie
In A1 - worker with oldest task Date/Time Assigned. Cell B1 contains the answer to cell A1 by providing the employees name.
I enter the data in the individual workers spreadsheets (Amy, Betty, Connie) and my Data worksheet provides the summary. On my data worksheet, I have formulas that count the number of tasks within the last 7 days and last 30 days by using the date/time assigned column (Column E)in the individual worksheets. Currently, if someone is out of the office, on their individual worksheet, I enter OUT in the task column (Column B) and the date/time that they will return in the date/time assigned column (Column E)so it will skip them for B1 on my Data worksheet. I need a formula that would not count the date/time assigned if they were OUT as a task, when calculating in columns B and C in the data worksheet.
Here is the formula that I have currently for Column B (total tasks last 30 days)
{=COUNTIF(INDIRECT("'"&A4&"'!"&"E1:E1000"),">="&(NOW()-30))}
The formula that I have for cell B1 is:
{=INDEX(A4:A14,MATCH(MIN(E4:E14),E4:E14,0))}
Any help would greatly be appreciated.
I figured it out:
=COUNTIFS(Amy!E2:E1000,">="&(NOW()-30),Amy!A2:A1000,"<>out")
Like suggested in the comments, the COUNTIFS formula is what you want to use. Information about its usage can be found here.
Adding the condition for excluding the "OUT" values would make the formula look like this:
=COUNTIFS(INDIRECT(""&A4&"!"&"E1:E1000"),">="&(NOW()-30),INDIRECT(""&A4&"!"&"B1:B1000"),"<>OUT")

Resources