Can COUNTIFS include simple formula as criteria (x - y > z) - excel-2010

Excel 2010
I have a COUNTIFS formula I'm creating. So far, I have the following, which works great:
=COUNTIFS(Manager, $A7, Created Date,"<="& variable date, Closed Date, "<="& variable date)
The problem is I need to add another if-clause that counts only if 'variable date - Created Date > 14'. I can't figure out if it's possible or how I would do it. If it is possible, what criteria_range would I use and what would be the proper syntax (including quote marks) for the formula portion.
Any ideas?

In case anyone is interested, after some additional research, I ended up with the following formula:
=SUMPRODUCT(--(Manager=$A7),--(variable date-Created Date>14),--(Closed Date>variable date))
I don't completely understand the resulting formula but it did do what I needed it to do.

Related

How to use SUMIFS on several lines, using dates

I am trying to sum values using sumifs but I am getting an error. Went throught several website but I guess I don't have a good understanding of how SUMIF works.
Right now I have a sheet with a registry date(C), a price per weeek(G) and a end date(D).
I would want to calculate the earning every week.
So I created another sheet with every week of the year.
=SUMIFS(Clients!G2:G;A5;>=Clients!C2:C;A5;<=Clients!D2:D)
I am not using coma as a separator as my google sheet is not in english.
I am trying to sum the incomes if the date on the second sheet is between the starting date and the end date. But I keep getting errors and I don't really unerstand why.
Thanks
I found an formula which look to be working.
=SUMIFS(Clients!G2:G;Clients!C2:C;"<="&A5;Clients!D2:D;">="&A5)
I guess that it was not working because I was letting A5 to incremente.
Problem solved.
Thanks for your help.
Find out more here on Google's post about =SUMIFS().
Sample usage
SUMIFS(A1:A10, B1:B10, ">20")
SUMIFS(A1:A10, B1:B10, ">20", C1:C10, "<30")
SUMIFS(C1:C100, E1:E100, "Yes")
Syntax
SUMIFS(sum_range, criteria_range1, criterion1, [criteria_range2, criterion2, ...])
sum_range – The range to be summed.
criteria_range1 – The range to be checked against criterion1.
criterion1 – The pattern or test to apply to criteria_range1.
criteria_range2, criterion2, … (OPTIONAL) – Additional ranges and criteria to be checked.

Google sheets Combining Query with Today() [duplicate]

This question already has an answer here:
How to compare dates or date against today with query on google sheets?
(1 answer)
Closed 5 months ago.
I would like to use the today function in a query. Right now I have to manually change the date each morning, which is time consuming. The query is:
=QUERY(StageTracking!A:W, "SELECT C where A =date'2021-05-13'")
When I try
=QUERY(StageTracking!A:W, "SELECT C where A =today()")
I get a #VALUE error.
I know it's just a syntax thing I'm not catching but I have tried many variations on the line above.
Let me offer another (perhaps simpler) option, given what I can tell from your post info.
Add a header in the top cell of your results column and put the following formula into the second cell of that otherwise empty column:
=FILTER(StageTracking!C2:C,StageTracking!A2:A=TODAY())
ADDENDUM (after seeing the actual sheet):
This is an excellent case in point of why it is always most efficient and effective to share a link to a sheet, since your formula attempts as originally posted (and mine as posted above) would not work with your actual layout and goal.
I've added a new sheet ("Erik Help").
First, I un-merged Rows 2-8 and simply increased the height of Row 2. There was no reason to merge those rows; and merging nearly always causes issues, especially in ranges where formulas or reference ranges are involved.
Next, I deleted your original A2 formula (=QUERY(StageTracking!A1:W1000,"select C where A = '06/23/2021'",1)) and replaced it with the simple =StageTracking!C1, which accomplishes the same thing. Again, I'm not sure what led to the long formula, but it was unnecessary.
I then deleted all of your individual erroneous formulas from B2:K2 and replaced them with one formula in B2:
=FILTER(FILTER(StageTracking!E2:W,StageTracking!A2:A=TODAY()),ISODD(COLUMN(StageTracking!E1:W1)))
This formula first creates a FILTERed array of everything from E2:W where A2:A = TODAY(). Then a second FILTER is applied to bring in only the odd columns.
NOTE: currently, while the formula is working, you will see no results in E2:W because you don't have any data for TODAY in your StageTracking sheet yet. Once you add data for today's date, you will see the formula populate B2:K2. (Or, you can simply add -1 after TODAY() in the current formula if you want to see the results from "yesterday" temporarily, in order to be sure the formula is, in fact, working.)
Try this:
=QUERY(StageTracking!A1:W1000,"select C where A = '06/23/2021'",1)
or
=QUERY(StageTracking!A1:W1000,"select C where A = date '"&TEXT(TODAY(),"yyyy-mm-dd")&"'",1)
Take a few minutes to review the scalar functions supported in the QUERY() function.
https://developers.google.com/chart/interactive/docs/querylanguage#scalar_functions
You can use YEAR(), MONTH(), DAY() or NOW(). NOW() is a compete datestamp including time, so that would require more effort.

Google Spreadsheet SUMIF with criterion containing wildcards

Please see the data example in the image below...
I would like to sum the amounts separately by months and years.
How can I do this using SUMIF ?
My idea was very simple - to have formula for each month and for each year, like this:
=SUMIF(A1:A100,"2018-01-*",B1:B100)
=SUMIF(A1:A100,"2018-02-*",B1:B100)
=SUMIF(A1:A100,"2018-03-*",B1:B100)
..etc
=SUMIF(A1:A100,"2018-*",B1:B100)
=SUMIF(A1:A100,"2019-*",B1:B100)
..etc
But this formulas don't work. Something is wrong with the criterion.
So what am I doing wrong ? Am I using wildcards incorrectly ?
Example of data that I have
The problem here is that cells containing dates are special and cannot be compared to criterion like 2018-08-*.
The workaround is to use SUMIFS and then set each criterion with the DATE() function. Here is example for 2018-07:
=SUMIFS(B2:B100,A2:A100,">="&DATE(2018,7,1),A2:A100,"<"&DATE(2018,8,1))
You could use Query as in the image below (showing sum for 8th month - August):
By changing month(A)+1=8 you will have different months.
Code:
=QUERY(A1:B5;"select sum(B) where month(A)+1=8 label sum(B) ''";0)
Is that OK for you?

Use SUMIFS in an ArrayFormula Google Sheets

I've already seen a lot of topics about my problem, but I can't resolve it.
Actually, I don't understand what is wrong in my formula ?
=ArrayFormula(
IF(
ISBLANK(A6:A);;SUMIFS(
Sheet1!J:J;
Sheet1!K:K; ">="&A6:A;
Sheet1!K:K;"<="& EOMONTH(A6:A;0)
)
)
)
What I'm trying to do :
Each line is a month. I want to SUM all sales made between the first day on the month, and the last one.
If I don't use ArrayFormula, it works. I dont understand how to write this formula to work with ArrayFormula.
Thank you very much for your help !
Just adding this as an answer for you,
Instead of using an array formula, I believe a query would serve you better.
as google date-time syntax is tricky we first have to convert the date value into a text and parse it as "yyyy-mm-dd" we then wrap the EOMONTH to get the last day of the month.
so we use the following formula to get the sum of the months sales:
=query(A:B;"Select sum(B)
where A <= date '"&text(eomonth(E14;0);"yyyy-mm-dd")&"'
AND A >= date '"&text(E14;"yyyy-mm-dd")&"' label sum(B) '' ";0)
hopefully, this is what you were after, apologies for the delay was on the train!
https://docs.google.com/spreadsheets/d/1ygppZZCd4b_Y_HufLwLdcynHAsa3pn6z5YXb3Poc3vk/edit?usp=sharing

IsDate ArrayFormula

Have just noticed isDate does not work in arrayformula.
Case
Want to filter all values if dates:
Used the formula:
=FILTER(data,ISDATE(data))
Expected result:
8/28/2018
Got:
#N/A
Question
Why? Other checks work in filter (isNumber, isText, isErr).
Workarounds?
Please try:
=ARRAYFORMULA(ISDATE_STRICT(A1:A11))
The function is currently not documented.
🧐: ISDATE_STRICT wont let date&time format, dates only
Do not know the reason, still curious.
Workaround: =FILTER(data,IFERROR(DATEVALUE(data))) was found here
Note: Workaround will NOT work for dates formatted as:
dd.mm.yyyy
You may use a duck-typed workaround:
=FILTER(data,REGEXMATCH(MID(data,7,4),"20\d{2}"))
Will check if formatted date has a 20XX year string inside.
Now you can convert any formula to arrayformula:
=BYROW(A2:A12,LAMBDA(r,ISDATE(r)))
A workaround that could work depending on what you're trying to do as far as Arrayformula is concerned
=ARRAYFORUMLA(ISNUMBER(VALUE(data)))
VALUE can turn the time into a number
ISNUMBER checks if it's a number
ISNUMBER works fine within ARRAYFORMULA

Resources