How can I customize when the week starts with Keen IO request?

Is it possible to define the start and end day of the week in Keen IO query language? I have a request like:

var query = new Keen.Query("count", {
    eventCollection: "add_to_carts",
    timeframe: "previous_2_weeks",
    interval: "weekly"
});

      

By default, my query shows a week starting from Sunday and runs until Saturday, but I need my data to start on Saturday - is this possible?

We want to find data for the current week and the previous week in a single query (using intervals) and split the results of two weeks for comparison - every week from Saturday to Friday.

+3


source to share


1 answer


This would be possible with absolute timeframes and defining a custom interval, for example:

var query = new Keen.Query("count", {
    eventCollection: "add_to_carts",
    timeframe: {
        start: "2016-08-01",
        end: "2016-09-12"
    },
    timezone: "US/Pacific",
    interval: "every_7_days"
}); 

      

Instead of using "weekly", the custom interval definition "every_7_days" is used. This would actually be one query starting on Saturday some time in the past, and you would get as many interval results as there are 7-day blocks from this Saturday - essentially creating the previous week and this week in the response.



Here's a fiddle that shows this query and the resulting diagram.

enter image description here

+3


source







All Articles