You can use Date/Time variables in crosstabs with other variables to see trends over time. Date/Time variables in Displayr have a special Date/Time aggregation menu that determines how the dates are configured in tables and analyses. Many times, you can avoid writing code to create special date variables and instead use the Date/Time settings to create special durations and date ranges. 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 (quarters, years, etc)
- Change the dates shown to the latest period(s) (Duration)
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