You can use Date/Time variables in crosstabs with other variables to see trends over time, perform significance testing against the previous period, and perform date calculations. Variables with a Structure of Date/Time in Displayr are dates based on a timeline (versus being general category labels). This is so you can do calculations on time between dates, show space for missing dates, and ensure your dates are always in order.
Displayr makes it easy to configure your dates to show different periods of time to compare trends and do testing. In the variable's object inspector there is a special Date/Time button that leads to an aggregation menu where you can configure your date via point and click versus writing code. This menu allows you to specify what interval of period you want to use (Aggregation) and the range of dates displayed. Below is a list of examples of how to configure your date based on various needs:
- Change the type of dates shown in tables (Aggregation)
- Change the start/end of your dates (Date Range)
- Change the start/end of your date aggregations (i.e. fiscal quarters, fiscal years, etc)
- Change the dates shown to the latest period(s) (Duration)
Requirements
- A variable with a Structure > Date/Time. If you have a date variable that isn't structured as a Date/Time variable, there are various ways to convert it, see How to Create Date Variables in Displayr.
Change the type of dates shown in tables (Aggregation)
Date variables are a list of dates that represent a point in time, i.e. 1/2/2022 or 2/3/2022 00:00:00. When you analyze Date/Time data you will want to combine the dates into larger aggregations such as daily, weekly, monthly, etc. You can set the following aggregations in Displayr as well as the number:
For example, a Date/Time variable setup with Aggregation > 1 Month will show as follows in a table:
Changing that to Aggregation > 1 Quarter will show typical quarters in the table instead:
Change the start/end of your dates (Date Range)
A Date/Time variable will automatically show all of the data in the data set. You can modify this to only show data for a specific date range by changing Period > Date Range and using the Minimum and Maximum fields. Below I've done this using April 2019:
which shows:
Change the start/end of your date aggregations (quarters, years, etc)
A Date/Time variable will automatically use the standard start and end times for aggregations. This means Quarter 1 is Jan-Mar, Quarter 2 is Apr-Jun, etc. However, sometimes organizations will have their own fiscal schedules to use where Quarter 1 is Feb-Apr, Quarter 2 is May-Jul, etc. You can change your Date/Time variable in Displayr to reflect these non-regular time frames. The key to this is setting the Maximum date in your Period > Date Range to the end of one of the time frames in the future (this will account for when you receive more data).
For example, the Maximum date on the date variable below is the end of July in the next year - so the quarters will be set to be one month later than the regular quarters:
which shows:
You can use How to Hide Empty Rows and Columns in a Table to hide empty dates in the future or use the most recent quarter-end date as the Maximum and update it when data changes.
Change the dates shown to the latest period(s) (Duration)
Many times you may want to have multiple versions of your date variable in your file to show tables/analyses for different time frames. With trackers, it's typical to show tables with historical data as well as tables focusing on the change over the last few periods. To create a variable for the last few periods, you can use Period type > Duration in the Date/Time menu. For example below, I want to show monthly dates in the latest quarter of data:
which shows:
You could also set Duration > 3 Months if you wanted to show the most recent 3 months regardless of the quarter they're in. If you're working with dates with non-typical start/end times, you should instead create a filter to find the latest periods in your data. See How to Dynamically Filter Data to the Latest Waves.
Note, when you apply a filter that removes a range of dates from this variable, then the dates shown in your table will change accordingly. For example, if your date question contains dates from January to December, and you configure it to show the last 6 months, then you will see July, August, September, October, November, and December. If you filter that table to dates before 1 October then you will see April, May, June, July, August, and September.
Next
How to Conduct Significance Tests by Comparing to Previous Time Periods
How to Abbreviate Month Labels in Tables
How to Work with Date Ranges Using R
Watch our Understanding Variable Sets video