Count if a value is between two dates - count

I have a column that shows the date a task was completed. Some rows are blank, which means the task is still being worked on (and can be disregarded)
I am trying to write a measure that counts the number of rows which are between a start date and an end date. For example, in the table, there are three rows which are 10-aug-2022. I tried the following
Closed Tickets = COUNT(datesbetween(Issues[ISSUE_RESOLVED],DATE(2022,07,09),DATE(2022,08,11)))
I get the error that The COUNT function only accepts a column reference as an argument. I need the number 3 returned.
I think I need to use a different function to count if (since I want to specify a particular date in the expression and not reference another column). I was working on the following, but I cant get the right syntax
Closed Tickets = calculate(COUNT(Issues[ISSUE_RESOLVED],FILTER(Issues,Issues[ISSUE_RESOLVED]>=DATE(2002,08,9)&&Issues[ISSUE_RESOLVED]<=DATE(2002,08,11)
Any help would be appreciated :)
edit - I also tried the following
Closed Tickets = COUNTROWS(FILTER(Issues,Issues[ISSUE_RESOLVED]>=DATE(2022,8,11)&&Issues[ISSUE_RESOLVED]<=DATE(2022,8,11)))
But Im getting in my table when expect 12

Found it.
Closed Tickets (JULY) = COUNTROWS(FILTER(Issues,Issues[ISSUE_RESOLVED]>=DATE(2022,7,15)&&Issues[ISSUE_RESOLVED]<=DATE(2022,8,15)))

Related

Looking up data based on two parameters (including a date) in R

I am new in R and already found a lot of answers on this site, but with this one, I am stuck.
I have a table (in Excel, see image in link) that gives me a value (called c) based on class (0 to 6) and start date (17/2018, 1/7/2019, 1/7/2020 and so on). In my dataframe there is a colum 'date' and a column 'class'. For every row in the dataframe, I need to find the corresponding c-value (so if class = 2 and date = 15/10/2018, I need the value 659,86 in a new column).
I have to problems:
- when importing the data in R, it sets an "X" before the date
- I don't know how to do the lookup with dates (with exact values, I manage with merge).
Hope my question is clear and somebody can help me.
Thanks!
steven

How to print the number of data entries inside a variable in R? [duplicate]

This question already has answers here:
How to know a dimension of matrix or vector in R?
(6 answers)
Closed 3 years ago.
I know this is probably a very simple question but I can't seem to find the answer anywhere online. I am trying to print just the number of data points inside of a variable that I created but I can't figure out how.
I tried using summary() or num() or n() but I am really just making stuff up here and cannot seem to figure it out at all.
For my specific example I have a data set on peoples heights, age, weight, gender, stuff like that. I used
one_sd_weight <- cdc$weight[abs(cdc$weight - mean(cdc$weight)) <= sd(cdc$weight)]
to determine how many of the weights fall within one standard deviation of the mean. After I do this, I can see that on the right side it created a new variable called one_sd_weight that contains 14152 out of the original 20000 entries. How do I print the number 14152 as a variable? For the work I am doing I need to create a new variable that just contains one number, 14152 or whatever number is produced when I run the code above. For example, I need to create
n_one_sd <- 14152
without typing in 14152, instead typing some function that grabs the number of entries in one_sd_weight.
I have tried things like summary() and n() but only receive error messages in return. Any help is greatly appreciated!!
n_one_sd <- length(one_sd_weight)
You're looking for length (in case of a vector) or nrow in case of a matrix/data.frame.
Or you can use NROW() for both, that should work too.

Query based on Today's date [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 have a Google Spreadsheets document with two sheets in it. The first sheet is where I want to run my query. Located in cell B1 is today's date with the formula =today(). I have headers in row 2. So I want the query to start in A3. My information is in the second sheet cells A38:M1267. I only want the query to pull columns B, D, F, K. Column A has the dates. I want to run the query based on today's date and match all the dates in column A of the second sheet and return the values.
The query formula I have tried:
=QUERY(Season!A38:M1257,"SELECT A,D,F,K, Where A ="&B1&"")
keeps coming up with #Value. I have spent the last few hours trying to rewrite it to get it to work and I just don't know what is wrong.
Please try:
=QUERY(Season!A38:M1257,"SELECT B,D,F,K where A = date '"&text(B1,"yyyy-MM-dd")&"'")

Specific date format conversion problems in R

Basically I want to know why as.Date(200322,format="%Y%W") gives me NA. While we are at it, I would appreciate any advice on a data structure for repeated cross-section (aka pseudo-panel) in R.
I did get aggregate() to (sort of) work, but it is not flexible enough - it misses data on columns when I omit the missed values, for example.
Specifically, I have a survey that is repeated weekly for a couple of years with a bunch of similar questions answers to which I would like to combine, average, condition and plot in both dimensions. Getting the date conversion right should presumably help me towards my goal with zoo package or something similar.
Any input is appreciated.
Update: thanks for string suggestion, but as you can see in your own example, %W part doesn't work - it only identifies the year while setting the current day while I need to set a specific week (and leave the day blank).
Use a string as first argument in as.Date() and select a specific weekday (format %w, value 0-6). There are seven possible dates in each week, therefore strptime needs more information to select a unique date. Otherwise the current day and month are returned.
> as.Date(paste("200947", "0", sep="-"), format="%Y%W-%w")
[1] "2009-11-22"

Count repeated values in a column

I have a column of year values by which I am sorting. I'd like to find the quantity per year (read: number of repeats of each year value). I'd like to chart said values. I'm not sure how to make this happen.
I am using Apple's Numbers '08, but if possible a general solution that multiple people could use would be preferred.
You should use the countif() function: http://office.microsoft.com/en-us/excel/HP052090291033.aspx
I did a similar thing to count how many hours of work there are for each upcoming version of my iPhone app. I was doing sumif(), but you just want countif().
See cells N4-N6 here: http://spreadsheets.google.com/ccc?key=0AhL0igVI9HVNdGpaS3U1cS1qOGVNd3h0Slg0a21vUWc&hl=en
On a new sheet, list the unique years in one column, then their quantity count in the column next to them. Select the entire range created, then create a chart.
I'm unsure from your question what you would specifically need more than this (and I work in Excel 2003).

Resources