Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering in a date range #161

Open
aparada96 opened this issue Aug 30, 2023 · 4 comments
Open

Filtering in a date range #161

aparada96 opened this issue Aug 30, 2023 · 4 comments

Comments

@aparada96
Copy link

aparada96 commented Aug 30, 2023

I have the following code below. Is there a way to filter the selected date range in R but only capture specific hours? For example, I want to apply a date range filter for 30 days but only select results between the hours of 7pm and 10pm.

aw_freeform_table(rsid = 'worksite-prod',
                           date_range = c("2023-08-01", "2023-08-30"),    
                           metrics =  c("visitors","videototaltime"),
                           dimensions = c("videoname",'evar18','daterangeday'),
                           search =  "CONTAINS 'Baseball'",
                           prettynames = T,
                           segmentId = "s12345",
                           top = 30)

I know that I can filter for a specific time frame by applying: date_range = as.POSIXct(c("2023-08-29T19:00:00", "2023-08-29T22:00:00"), format = "%Y-%m-%dT%H:%M:%S"), but I wonder if there's a way to do this where I wouldn't have to apply/run this 30 times (for the 30 days). Thanks!

@charlie-gallagher
Copy link
Collaborator

There's a dimension called "Hour of Day" (api ID is timeparthourofday). You could make a segment for the hours that you want and apply that to your query with the segmentId argument. Alternatively you could request the hour of the day as a dimension, it all just depends on purpose

@charlie-gallagher
Copy link
Collaborator

Here's a quick version if you want an hourly breakdown:

aw_freeform_table(dimensions = 'timeparthourofday', search = "( CONTAINS '7:00 PM' ) OR ( CONTAINS '8:00 PM')")

@charlie-gallagher
Copy link
Collaborator

For a segment, this seems to work correctly

Screenshot 2023-08-30 at 4 35 56 PM

@benrwoodard
Copy link
Contributor

@aparada96 did @charlie-gallagher's solution solve this for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants