COUNTIF with IMPORTRANGE with date range and unique ID criteria - google-sheets

I haven't been able to find a solution to get this formula to work after multiple days of searching. The google spreadsheet we use is large and used by many people so I would like to keep this in a separate google sheet using IMPORTRANGE.
Data Needed:
Count of assignments a specific user completed within 7 days and after 7 days based on a start and end date.
Where I'm running into issues:
I simplified the equation by using a small data set in the same sheet to see the main issue. When giving a range for the user # the formula doesn't work anymore. When only comparing it to one user # at a time it does.
For example:
This doesn't work:
=COUNTIFS(C2:C-B2:B,"<7",A2:A,E2)
This one does but needs to have the range for the table to work:
=COUNTIFS(C2:C-B2:B,"<7",A2,E2)
I might be going about this all wrong. Any help I could get is much appreciated.

E2: =UNIQUE(FILTER(A2:A, A2:A<>""))
F2 and drag down: =COUNTIF(ARRAYFORMULA(DAYS(FILTER(C$2:C,$A$2:$A=$E2),FILTER(B$2:B,$A$2:$A=$E2))),"<=7")
G2 and drag down: =COUNTIF(ARRAYFORMULA(DAYS(FILTER(C$2:C,$A$2:$A=$E2),FILTER(B$2:B,$A$2:$A=$E2))),">7")

Related

How to combine data from multiple Google Sheets and organize/filter it?

Here's my sample spreadsheet: https://docs.google.com/spreadsheets/d/1c-nXosPZvnEplFME6GHXlxuQUrVe4ImF5c5Go9_75DU/edit#gid=34769607
I use an API to import data from our time tracking app into Google Sheets. The "Project Details" sheet has most of the info about the projects, except for the hours spent on each project. So I have a "Project Hours" sheet that has the hours spent.
I want to combine these two things into one list in a separate "Main" sheet, as well as leave out columns that I don't care about. I really only care about the project name, the client name, the start date, end date, and total hours.
There must be a simple formula to use that gives me a clean list of all the projects and only shows me the data I care about, like QUERY or ARRAYFORMULA, but I'm not very familiar with those. Any help would be appreciated!
Craig. Yes, a QUERY with a VLOOKUP can accomplish this. I added a new tab (clearly marked as mine) to your example sheet. Being thorough, I wanted to include the column header in the last column as well, which makes the formula a bit longer than it would otherwise be in that it uses the IFERROR wrap on the VLOOKUP to assign the header for Row 1 (or otherwise leaves the last column blank if no match is found for a project name).
Here's the formula I used (though other approaches could certainly have been used as well):
=ArrayFormula({QUERY('Project Details'!A:Y,"Select B, Y, P, Q Where A Is Not Null"),IFERROR(VLOOKUP(QUERY('Project Details'!A:A,"Select * Where A Is Not Null"),'Project Hours'!A:E,5,FALSE),IF(ROW('Project Details'!A:A)=1,'Project Hours'!E$1,""))})

Using a Named Range to identify worksheets to use a SUMIFS on a to add an array of data

Below is a sample of the Google Sheet I'm working on:
https://docs.google.com/spreadsheets/d/1LDsfn_FMdUSfuFZAyuXf5gdlOSN9yLqhT1RY8aX7Nfs/edit?usp=sharing
On the spreadsheet Team Totals, I'm trying to calculate all the sales based on the date, the type of sale, and the program type starting from Row 27.
The problem I have run into is that the Named Range, Consultants, only pulls the data from the first cell of the Named range (Octo). What I want is for a formula that will pull the data of the selected range from each entry in the named range and sum them together.
For reference, I put what the proper values should be starting from Row 33.
The closest example I have seen was from this website: https://www.got-it.ai/solutions/excel-chat/excel-tutorial/sumif/sumif-across-multiple-sheets
However, I get the same problem that only the first cell in the named range gets pulled.
I feel like I'm missing something simple, but I have been bouncing it around my head for hours and can't figure it out. Any help is greatly appreciated.
So after trying to figure out a way not to use an iterative process, I folded and did this:
=arrayformula(SUMIFS(INDIRECT("'"&$B$4&"'!F6:F100"),INDIRECT("'"&$B$4&"'!D6:D100"),$B$2,INDIRECT("'"&$B$4&"'!E6:E100"),E$27,INDIRECT("'"&$B$4&"'!A6:A100"),$A41)+
SUMIFS(INDIRECT("'"&$B$5&"'!F6:F100"),INDIRECT("'"&$B$5&"'!D6:D100"),$B$2,INDIRECT("'"&$B$5&"'!E6:E100"),E$27,INDIRECT("'"&$B$5&"'!A6:A100"),$A41)+
SUMIFS(INDIRECT("'"&$B$6&"'!F6:F100"),INDIRECT("'"&$B$6&"'!D6:D100"),$B$2,INDIRECT("'"&$B$6&"'!E6:E100"),E$27,INDIRECT("'"&$B$6&"'!A6:A100"),$A41)+
SUMIFS(INDIRECT("'"&$B$7&"'!F6:F100"),INDIRECT("'"&$B$7&"'!D6:D100"),$B$2,INDIRECT("'"&$B$7&"'!E6:E100"),E$27,INDIRECT("'"&$B$7&"'!A6:A100"),$A41)+
SUMIFS(INDIRECT("'"&$B$8&"'!F6:F100"),INDIRECT("'"&$B$8&"'!D6:D100"),$B$2,INDIRECT("'"&$B$8&"'!E6:E100"),E$27,INDIRECT("'"&$B$8&"'!A6:A100"),$A41)+
SUMIFS(INDIRECT("'"&$B$9&"'!F6:F100"),INDIRECT("'"&$B$9&"'!D6:D100"),$B$2,INDIRECT("'"&$B$9&"'!E6:E100"),E$27,INDIRECT("'"&$B$9&"'!A6:A100"),$A41))
This formula allows me to cut and paste it to various cells easily, and does the job I need it to, while still using the indirect reference so I can change names without breaking the formula (granted I change the worksheet name as well).
I will need to edit this to include all possible worksheet amounts I can forsee, but once it's done, I won't have to tinker with names anymore.
I'm not happy with this answer, as it creates a really long and ugly formula, essentially repeating the same formula 20 times, but it does work. I feel like there should be an easy function that would be able to do this.
This will return Total sales:
=if(isna(ArrayFormula(QUERY({Lo!$A$5:$F; Tulio!$A$5:$F;Ya!$A$5:$F; Miguel!$A$5:$F;Kevin!$A$5:$F; Octo!$A$5:$F}, "select sum(Col6) where Col1=date '"&TEXT(A28,"yyyy-mm-dd")&"' label sum(Col6) ''",0)))=TRUE,0,ArrayFormula(QUERY({Lo!$A$5:$F; Tulio!$A$5:$F;Ya!$A$5:$F; Miguel!$A$5:$F;Kevin!$A$5:$F; Octo!$A$5:$F}, "select sum(Col6) where Col1=date '"&TEXT(A28,"yyyy-mm-dd")&"' label sum(Col6) ''",0)))
BTW, I get Total sales of $0, $615.50 and $2,498.00
The best way to pull data from a lot of unknown tab names without a script is to actually CREATE the tab names beforehand. On your sheet it looks like you're anticipating/making space for 21 employees. If I were you, I would just create 15 more tabs named Temp7,Temp8,Temp9... etc. Then you can just "hide" those tabs. Then a formula can be built in your totals section that will easily stack all the tabs up using an array literal and a QUERY( { } ) to add up the totals for you without all this INDIRECT() nonsense that you have been going through to pull from the individual tab names.
Would pre-adding tab names be something you were interested in if I could show you the formulas to make the totals easy to calculate?

google sheet data filter for last a few days

I have a google sheet to log what I do at work every day.
for example
no filter
I managed to figure out how to filter it by today.
highlight colon -> data -> filter -> date is today
for example:
only today
but I could not figure out how to filter it by the last x number of days
for example:
goal
I guess I will need to make a custom filter, but I have a really hard time figuring out how to make custom filters in google sheet.
Please help me. Thanks in advance.
I solved this in two ways. One with a filter view, and one with a formula you could also use. Both are in my example spreadsheet based on your provided data.
Filter View:
To view my example use the above link and go to the sheet "Filtered". Then apply "Filter recent days" which is a filter I created. I created this filter by filtering column A for the condition "Date is after". I then chose "exact date..." which allows formula input. The formula I used was =TODAY()-4 which simply filters the data for every instance of column A which is after 4 days ago.
Filter formula:
To accomplish this, I left the original data in columns A and B. Then in C5, I entered the formula =FILTER(A3:B,A3:A>TODAY()-4), which uses basically the same method as above. This will produce a separate output next to your original data with only the recent entries.
I also took this a step further by moving the formula down a cell, and then replacing the 4 in the formula with D2. Now you can change the number in D2 to change how many days it displays.

Running total with two criteria - seeking arrayformula or app script

I have a google sheet with a list of [people], [dates], and [times]. I need a running total column that gives me a running time total on each line for each combination of name and date, as of that line. I have a working SUMIFS solution. The drawback of this solution is that it requires me to copy the formula down the entire column. Since I ultimately want this to work in a sheet that is fed by a form, I want to use either an ARRAYFORMULA or an APP SCRIPT solution, so that each new row will automatically do the calculation without my needing to copy down the formula.
You can see what I mean in this sample sheet:
https://docs.google.com/spreadsheets/d/1G6cgwwcL6LfnbVUhn8PrMYxrUSImkmgOGvPspparhSI/edit?usp=sharing
Thanks for any thoughts you may have.
-DH
SUMIF() does not play nice with ARRAYFORMULA(). Have a look at this MMULT example spreadsheet, last sheet "Cumulative sum down column", column U
https://docs.google.com/spreadsheets/d/1NJPAt5iFQWIyxHx35bpCh6zjVeKon4rdTPk-dfyZDrU/edit#gid=420781522
If you haven't used matrix multiplication before, and have trouble wrapping your head around the solution, try to follow the examples starting from the 1st sheet.

SUMIF with FIND as criteria

I'm trying to summarize data from several Google spreadsheet' sheets in a single one but I have some issues with SUMIF and FIND.
To Sum data from another sheet I have to use this (at least that's the only solution I've found)
=SUM(INDIRECT(""&A6&""&"!E2:E"))
Where I have the name of my sheet on A6.This makes everything easy because I have a column (A) with all the names of the sheets. I haven't found something like Sheets[1] in Google Docs.
My next step was to Sum Times from a specific column but remove a specific values, which in this case is 1 that get transformed internally 24:00:00 since it's a time column:
=SUM(INDIRECT(""&A6&""&"!D2:D")) - SUMIF(INDIRECT(""&A6&""&"!D2:D");"24:00:00")
Here I tried to do everything with a single SUMIF but I have no idea how. NOT("24:00:00") didn't work so I settled to this.
The last part is the most difficult and I'm not able to solve it.
I have a column with month names (for example) and I want to sum some data only when the month name contains "er". Here is what I thought:
=SUMIF(A6:A16,ISNUMBER(Find("er")),G6:G16)
This gives me always 0
(Note that the last one contains A6:A16 instead of the whole INDIRECT part because I am still testing it in a single sheet.)
Any Idea what I'm doing wrong?
I don't know why the above SUMIF doesn't work, what I've tested and works is:
=SUMIF(A6:A16,"*er*",G6:G16)
SUMIF is NOT SUM + IF as I thought. I hope it will help someone else.

Resources