| Title: | Time Intelligence and Customer Segmentation for Financial Analysis |
|---|---|
| Description: | Calculate time intelligence metrics for financial planning and analysis. 'ti' provides functions for period-over-period comparisons (year-over-year, month-over-month), period-to-date calculations (YTD, MTD, QTD), and customer segmentation (ABC analysis, cohorts). Supports standard and retail calendars (4-4-5, 4-5-4, 5-4-4) with both in-memory and database backends via 'dbplyr'. |
| Authors: | Alejandro Hagan [aut, cre] |
| Maintainer: | Alejandro Hagan <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 4.3.0 |
| Built: | 2026-11-02 22:05:39 UTC |
| Source: | https://github.com/cran/ti |
For your group variable, abc() will categorize which groups make up what proportion of the totals according to the category_values that you have entered
The function returns a segment object which prints out the execution steps and actions that it will take to categorize your data
Use calculate to return the results
abc(.data, category_values, .value)abc(.data, category_values, .value)
.data |
tibble or dbi object (either grouped or ungrouped) |
category_values |
vector of break points between 0 and 1 |
.value |
optional: if left blank, |
This function is helpful to understand which groups of make up what proportion of the cumulative contribution
If you do not provide a .value then it will count the transactions per group, if you provide .value then it will sum() the .value per group
The function creates a segment object, which pre-processes the data into its components
abc object
contoso::sales |> dplyr::group_by(product_key) |> abc(c(.1,.5,.7,.96,1), .value = gross_margin)contoso::sales |> dplyr::group_by(product_key) |> abc(c(.1,.5,.7,.96,1), .value = gross_margin)
This calculates the all-time cumulative sum of targeted value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
atd( .data, .date, .value, calendar_type = "standard", fiscal_year_start = 1, week_start = 7 )atd( .data, .date, .value, calendar_type = "standard", fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
atd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard")atd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard")
This function takes a data frame and a date column and generates a wide set of derived date attributes. These include start/end dates for year, quarter, month, and week; day-of-week indicators; completed and remaining days in each time unit; and additional convenience variables such as weekend indicators.
It is designed for time-based feature engineering and is useful in reporting, forecasting, time-series modeling, and data enrichment workflows.
augment_standard_calendar(.data, .date)augment_standard_calendar(.data, .date)
.data |
A data frame or tibble containing at least one date column. |
.date |
A column containing |
The function creates the following groups of attributes:
1. Start and end dates
year_start_date, year_end_date
quarter_start_date, quarter_end_date
month_start_date, month_end_date
week_start_date, week_end_date
2. Day-of-week fields
day_of_week – numeric day of the week (1–7)
day_of_week_label – ordered factor label (e.g., Mon, Tue, …)
3. Duration fields
days_in_year – total days in the year interval
days_in_quarter – total days in the quarter interval
days_in_month – total days in the month
4. Completed/remaining days
days_complete_in_week, days_remaining_in_week
days_complete_in_month, days_remaining_in_month
days_complete_in_quarter, days_remaining_in_quarter
days_complete_in_year, days_remaining_in_year
5. Miscellaneous
weekend_indicator – equals 1 if Saturday or Sunday; otherwise 0
All date-derived fields ending in _date are coerced to class Date.
A dbi or tibble containing the original data along with all generated date-based attributes.
The calculate() function takes an object created by a time function (like ytd(), mtd(), or qtd()) or a segment function (like cohort() or abc()) and executes the underlying transformation logic.
It translates the function blueprint into an actionable query, returning the final data table.
calculate(x, ...) ## S7 method for class <ti::ti> calculate(x, ...) ## S7 method for class <ti::segment_cohort> calculate(x, ...) ## S7 method for class <ti::segment_abc> calculate(x, ...)calculate(x, ...) ## S7 method for class <ti::ti> calculate(x, ...) ## S7 method for class <ti::segment_cohort> calculate(x, ...) ## S7 method for class <ti::segment_abc> calculate(x, ...)
x |
ti object |
... |
Not used. |
The TI and segment functions in ti—such as ytd() or cohort() and others—are designed to be lazy and database-friendly.
They do not perform the heavy data transformation immediately.
Instead, they return a blueprint object (of class ti,segment_abc or segment_cohort) that contains all the parameters and logic needed for the calculation.
calculate() serves as the execution engine.
When called, it interprets the blueprint and generates optimized R code or SQL code (using the dbplyr package) that is then executed efficiently on the data source, whether it's an in-memory tibble or a 'DuckDB' table.
This approach minimizes data transfer and improves performance for large datasets.
The resulting table will be sorted by the relevant date column to ensure the correct temporal ordering of the calculated metrics.
dbi object
x <- ytd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard") calculate(x)x <- ytd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard") calculate(x)
Database-friendly cohort analysis function.
A remake of https://github.com/PeerChristensen/cohorts, combining
cohort_table_month, cohort_table_year, and cohort_table_day into a single package.
Rewritten for database compatibility; runs entirely in SQL without writing tables.
cohort(.data, .date, .value, time_unit = "month", period_label = FALSE)cohort(.data, .date, .value, time_unit = "month", period_label = FALSE)
.data |
tibble or dbi object |
.date |
date column |
.value |
id column |
time_unit |
do you want summarize the date column to 'day', 'week', 'month','quarter' or 'year' |
period_label |
do you want period labels or the dates c(TRUE , FALSE) |
Groups your .value column by shared time attributes from the .date column.
Assigns each member to a cohort based on their first entry in .date.
Aggregates the cohort by the time_unit argument (day, week, month, quarter, or year).
Computes the distinct count of each cohort member over time.
segment object
This calculates the daily value compared to the previous day's value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
dod( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )dod( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
dod(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)dod(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)
This calculates the monthly cumulative sum of targeted value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
mom( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )mom( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
mom(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)mom(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)
This calculates the monthly cumulative sum of targeted value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
momtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )momtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
momtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard", lag_n=1)momtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard", lag_n=1)
This calculates the monthly cumulative sum of targeted value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
mtd( .data, .date, .value, calendar_type = "standard", fiscal_year_start = 1, week_start = 7 )mtd( .data, .date, .value, calendar_type = "standard", fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
mtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard")mtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard")
This calculates the monthly cumulative sum of targeted value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
mtdopm( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )mtdopm( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
mtdopm(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)mtdopm(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)
This calculates the monthly cumulative sum of targeted value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
pmtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )pmtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
pmtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)pmtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)
This calculates the quarterly cumulative sum of targeted value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
use calculate to return the results
pqtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )pqtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
pqtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)pqtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)
This calculates the weekly cumulative sum of targeted value for the previous week using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
pwtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )pwtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
pwtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)pwtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)
For each group, pytd() will create the running annual sum of a value based on the calendar type for the previous year compared to the current year calendar date
If no period exists, it will return NA
The function returns a ti object which prints out the summary of steps and actions that will take to create the calendar table and calculations
Use calculate to return the results
pytd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )pytd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
pytd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)pytd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)
This calculates the full quarter value compared to the previous quarter value respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
qoq( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )qoq( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
qoq(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)qoq(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)
This calculates the annual cumulative sum of targeted value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
qoqtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )qoqtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
qoqtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)qoqtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)
This calculates the quarterly cumulative sum of targeted value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
qtd( .data, .date, .value, calendar_type = "standard", fiscal_year_start = 1, week_start = 7 )qtd( .data, .date, .value, calendar_type = "standard", fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
qtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard")qtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard")
This calculates the quarterly cumulative sum of a targeted value and compares it with the previous full quarter's total value respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
qtdopq( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )qtdopq( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
qtdopq(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)qtdopq(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)
This calculates the full week value compared to the previous week value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
wow( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )wow( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
wow(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)wow(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)
This calculates the weekly cumulative sum of targeted value and compares it with the previous week's cumulative sum using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
wowtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )wowtd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
wowtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)wowtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)
This calculates the weekly cumulative sum of targeted value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
wtd( .data, .date, .value, calendar_type = "standard", fiscal_year_start = 1, week_start = 7 )wtd( .data, .date, .value, calendar_type = "standard", fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtdopw(),
yoy(),
yoytd(),
ytd(),
ytdopy()
wtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard")wtd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard")
This calculates the weekly cumulative sum of targeted value and compares it with the full previous week's total using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
wtdopw( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )wtdopw( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
yoy(),
yoytd(),
ytd(),
ytdopy()
wtdopw(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)wtdopw(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)
This calculates the full year value compared to the previous year value respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
yoy( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )yoy( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoytd(),
ytd(),
ytdopy()
yoy(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)yoy(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)
This calculates the annual cumulative sum of targeted value and compares it with the previous period's annual cumulative to date sum using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
yoytd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )yoytd( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
ytd(),
ytdopy()
yoytd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)yoytd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard",lag_n=1)
For each group, ytd() will create the running annual sum of a value based on the calendar type specified
The function returns a ti object which prints out the summary of steps and actions that will take to create the calendar table and calculations
Use calculate to return the results
ytd( .data, .date, .value, calendar_type = "standard", fiscal_year_start = 1, week_start = 7 )ytd( .data, .date, .value, calendar_type = "standard", fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytdopy()
ytd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard")ytd(contoso::sales,.date=order_date,.value=quantity,calendar_type="standard")
This calculates the full year value compared to the previous year value using a standard or 5-5-4 calendar respecting
any groups that are passed through with dplyr::group_by()
Use calculate to return the results
ytdopy( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )ytdopy( .data, .date, .value, calendar_type = "standard", lag_n = 1, fiscal_year_start = 1, week_start = 7 )
.data |
tibble or dbi object (either grouped or ungrouped) |
.date |
the date column to group by. Must be a Date or POSIXt type. |
.value |
the value column to summarize. Must be numeric. |
calendar_type |
select either 'standard', '445', '454', or '544' calendar, see 'Details' for additional information |
lag_n |
the number of periods to lag |
fiscal_year_start |
integer 1-12, the month the fiscal year starts nearest to (default 1 = January). Only used with the retail calendars ('445', '454', '544'); the standard calendar always uses calendar years, and a message says so if you change it there. |
week_start |
integer 1-7, the day weeks start on (1 = Monday, 7 = Sunday, the default). On the standard calendar it affects only the week functions ( |
This function creates a complete calendar object that fills in any missing days, weeks, months, quarters, or years
If you provide a grouped object with dplyr::group_by(), it will generate a complete calendar for each group
The function creates a ti object, which pre-processes the data and arguments for further downstream functions
NA Handling
NA values in the .value column propagate through cumulative sums (cumsum returns NA once an NA is encountered)
NA values in the .date column are excluded from the calendar join and will not appear in results
Missing dates (gaps in your data) are filled with 0 values, not NA
standard calendar
The standard calendar splits the year into 12 months (with 28–31 days each) and uses a 7-day week
It automatically accounts for leap years every four years to match the Gregorian calendar
5-5-4 calendar
The 5-5-4 calendar divides the fiscal year into 52 weeks (occasionally 53), organizing each quarter into two 5-week periods and one 4-week period.
This system is commonly used in retail and financial reporting
ti object
Other time_intelligence:
atd(),
dod(),
mom(),
momtd(),
mtd(),
mtdopm(),
pmtd(),
pqtd(),
pwtd(),
pytd(),
qoq(),
qoqtd(),
qtd(),
qtdopq(),
wow(),
wowtd(),
wtd(),
wtdopw(),
yoy(),
yoytd(),
ytd()
ytdopy(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)ytdopy(contoso::sales,.date=order_date,.value=quantity,calendar_type='standard',lag_n=1)