Google Sheets - Count Unique Values of Importrange Data between Given Dates - google-sheets

I have a sheet with a Name Column and corresponding Date column. I'm attempting to count the number of times unique Names appear for a specific Date range. The data is in a separate spreadsheet, so I'm using importrange in the formulas.
I created a sample spreadsheet here - we can pretend that the "Data" tab is on a separate spreadsheet file. I have the below formula so far but I'm not sure how to tell it to only count the unique Name values between the Dates in cells B2 and C2.
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1VHR-T9bo0E1KH4yZp-9wTW6JGjKh4b3qMdm99MP_vB8/edit#gid=0","Data!A:B"),"Select Count(Col1) where Col2 >= date '"&TEXT(B2,"yyyy-mm-dd")&"' and Col2 <= date '"&TEXT(C2,"yyyy-mm-dd")&"' Label Count(Col1) ''")
Thanks for your help!

This formula should do it:
=COUNTUNIQUE(QUERY(IMPORTRANGE("1VHR-T9bo0E1KH4yZp-9wTW6JGjKh4b3qMdm99MP_vB8","Data!A2:B"),"select Col1 where Col2 >= date '"&TEXT(B2,"yyyy-mm-dd")&"' and Col2<= date '"&TEXT(C2,"yyyy-mm-dd")&"'",0))

Related

Datetime comparison query

I have an importrange array to get data from alot of sheets. I organise zhem into one list and then make calculations from this list.
WORKBOOK
https://docs.google.com/spreadsheets/d/1OH_LF9r04rRb1ZMuc26CwIq3NQ-qWVlb8mXJwuTechk/edit#gid=28668687
SOURCE WORKBOOK (Tracker)
https://docs.google.com/spreadsheets/d/1huVGusrmhZ60zy9pg59PKN_yfL1XulwvLW5EWwHguvA/edit#gid=2007038591
sheet MODTANEWBIE_QUERY
formula #1 (add UID to DATE):
=IF($B$2="No","",ARRAYFORMULA({MODTANEWBIE_PER!A$3&"#"&QUERY(IMPORTRANGE(MODTANEWBIE_PER!$C$3,"Tracker!"&B$3&":"&B$4&MODTANEWBIE_PER!$D$3),"select Col1 WHERE Col1 = "&A2)}))
formula #2 (get data from specific column in #Tracker based on date)
=IF($B$2="No","",ARRAYFORMULA({QUERY(IMPORTRANGE(MODTANEWBIE_PER!$C$3,"Tracker!"&B$3&":"&B$4&MODTANEWBIE_PER!$D$3),"select Col1 WHERE Col1 = "&A2)}))
For some reason I an unable to query the importrange's Date that corresponds to the cell A2 in _QUERY sheet.
Please am I missing something silly? Is there a format problem?
Thanks alot for any help!
formula should be:
=IF($B$2="No",,ARRAYFORMULA(MODTANEWBIE_PER!A$3&"#"&QUERY(IMPORTRANGE(MODTANEWBIE_PER!$C$3,"Tracker!"&B$3&":"&B$4&MODTANEWBIE_PER!$D$3),"select Col1 WHERE Col2 = date '"&TEXT(A2, "e-m-d")&"'")))
however:
tracker sheet does not contain today's date so A2 needs to be a valid date
dates on tracker sheet are in column B so B4 cant be A
query will then look for where Col2 where dates are
and query is picky on dates if they are not in this format: yyyy-mm-dd

How to sum values for each day in google sheets

I want to make two columns one that has date and the other that has sum for the number of violations occurred on that day. Have a look at the data below.
use:
=QUERY({B:C}; "select Col1,sum(Col2) where Col1 is not null group by Col1 label sum(Col1)''")

Total by day in google sheets for a given month and year

I have the following table:
What I'm trying to do is to write a formula that totals by each unique day in the month and year given in B1 and C1 thus the output should be:
I'm not sure how to start with this, googling seems to suggest the use of SUMIF.
Sheet is here
try:
=QUERY(FILTER({A5:B, TIMEVALUE(C5:C)}, MONTH(A5:A)=MONTH(B1&1), YEAR(A5:A)=D1),
"select Col1,sum(Col3)
where Col1 is not null
group by Col1
label sum(Col3)''
format sum(Col3)'[hh]:mm'", 0)

Variable named range cell references in Queries

The primary sheet has one column with dates; and thousands of rows on this sheet.
There are hundreds of other sheets, named by date. The format of each of these other date sheets is identical.
I need a query that can use each date on the primary sheet as reference to query a corresponding date sheet.
I would like to drag this formula down across all rows, and have the formula ref the date in the row rather than manually enter each cell.
Since I can't name the date sheets by date alone, I will need a naming formula that adds a word to the dates.
I've tried applying Named-Ranges to the date sheets and referencing them in the cells with import-range, but this did not work. I also tried inserting a link to the named ranges in each date cell, but this did not work either.
I've attached a screen grab of the idea. The data is just for illustration, it is fake. Sorry if this is a dumb question, I'm new to this, experimented, researched, could not find a solution. Thanks!
try:
=QUERY({INDIRECT("C"&ROW(C8)&"!A:H")},
"select Col5,Col8
where Col3 > date '"&TEXT(C8, "yyyy-mm-dd)&"'
and Col4 = 'SALE'
and Col5 <= "&D8 + (D8*E8)&"
and Col8 < 1
and Col8 > 0.01
order by Col8
limit 1", 0)

use Google Sheets QUERY to sum column weeknum = weeknum on a different sheet

I have a spreadsheet with 2 sheets in it, I want to summarize the weekly results by date. I'm trying to use the query sum function to summarize everything since I wasn't able to do it with arrayformula.
but I'm not able to do it with a query as well. I don't want to just copy-paste the sum function from each row to the next I want to just type the date I need in column A and get all the results in the different columns.
https://docs.google.com/spreadsheets/d/1ZsKXw32ycO_5KGD2I-Ug_GmqSIB_Z-D3Z1jlGd6fpTE/edit?usp=sharing
link to sheets.
getting the data from the database sheet. I want to display the data-oriented by date and summed.
=ArrayFormula(IFERROR(FILTER(QUERY(DataBase!A2:E,"select A,sum(E)
where A is not null
group by A
label sum(E)''"), WEEKNUM(DataBase!A2:A)=WEEKNUM(A2:A))
))
I tried this formula and it dosent work..
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A,
QUERY(FILTER(DataBase!A2:E,WEEKNUM(DataBase!A2:A)=WEEKNUM(A2)),
"select Col1,sum(Col5)
where Col1 is not null
group by Col1
label sum(Col5)''"), 2, 0)))

Resources