Toggle navigation
Home
▼ Details
Products and pricing
Chart gallery
User stories
Text analytics
CDC NAMCS Library
Blog
Tutorials
Contact
Sign in
Post Editor
← All blog posts
View post
Save
<p><style>img { margin: 20px auto; }</style> <img src="/images/tutorial/date/chart-cumulative-crosstab.png" style="width:360px; max-width:360px; display: block;vertical-align:top"></p> <p>Your survey data might have one or more columns with date values. There are lots of ways you can parse and analyze dates in Protobi.<p> <!--more--> <p>For instance, most surveys have an interview completion date:</p> <p><img src="/images/tutorial/date/date-string-iso.png" style="width:180px; max-width:300px; display: block;vertical-align:top;"></p> <p>Unless your data file identifies the column as date values, Protobi interprets date strings like any other string, and shows a distribution of the string values, treating each string as a categorical value:</p> <img src="/images/tutorial/date/date-marginal-str.png" style="width:360px; max-width:360px; display: block;vertical-align:top"> <h2>Parse dates</h2> <p>You can identify an element as date values by selecting "More properties..." from the edit icon and setting type to "Date". (You can also do this in the "Edit Json..." dialog by setting <code>"type": "date"</code>.) <img src="/images/tutorial/date/date-properties.png" style="width:360px; max-width:360px; display: block;vertical-align:top"> <p>Protobi now parses the date strings as Date values. It's really subtle but you can see that Protobi is now displaying values in ISO Strings a "Z" at the end, indicating that it recognizes and interprets the strings as Date values not just strings.<br><img src="/images/tutorial/date/date-marginal-iso.png" style="width:300px; max-width:300px; display: block;vertical-align:top"> <p>Here Protobi was able to easily interpret the strings because they came in a standard date time format that is recognized by all browsers. This particular format, <b>YYYY-MM-DD[T]HH:MM:SS[Z]</b> is in ISO 8601 format. It might look unusual but this is the international standard date format, as noted in this <a href="https://xkcd.com/1179/" _target="xkcd">XKCD Cartoon</a> (other formats exist like RFC 2822)</p> <h2>Custom date formats</h2> <p>It's possible your dates come in a different reasonable but non-standard format. Below we see dates in the format "MM/YYYY".</p> <img src="/images/tutorial/date/date-marginal-mmyyyy.png" style="width:360px; max-width:360px; display: block;vertical-align:top"> <p>Protobi already includes the leading date-time library <a href="https://momentjs.com/docs/#/parsing/">moment.js</a> and can parse a very wide variety of dates. To specify a specific format, select "Edit JSON..." from the edit icon and in the editor add the attribute <code>"dateFormat": "MM/YYYY"</code></p> <h2>Cumulative charts</h2> <p>Protobi charts recognize date values. For instance set the chart type to Cumulative:</p> <img src="/images/tutorial/date/chart-type-dialog.png" style="width:300px; max-width:300px; display: block;vertical-align:top"> <p>The chart now shows a cumulative distribution with the date values on the horizontal axis:</p> <img src="/images/tutorial/date/chart-cumulative.png" style="width:360px; max-width:360px; display: block;vertical-align:top"> <h2>Transform dates</h2> <p>You can transform dates as well. Here survey respondents completed surveys throughout the day. We can cluster the date values into discrete days by setting <code>"transform":"day"</code>:</p> <p><img src="/images/tutorial/date/chart-cumulative-day.png" style="width:360px; max-width:360px; display: block;vertical-align:top"></p> <p>(Here we also added markers by using the Plotly option, <code>"chartOptions.mode": "lines+markers")</code> to make it easy to see that values are grouped into discrete days.)</p> <p>Other options are <code>"year", "month", "day", "hour", "minute", "second"</code>. These are still date values, while rounded to the nearest value, they still retain their broader context like year, so "Feb 17, 2017" and "Feb 17, 2018" are different days.</p> <p>Alternately we can combine values by day name or month name, by setting <code>"transform"</code> to <code>"dayofweek"</code> or <code>"monthofyear"</code>. These include the integer index so that they sort correctly:</p> <p><img src="/images/tutorial/date/marginal-dayofweek.png" style="width:360px; max-width:360px; display: block;vertical-align:top"></p> <p>Date and time charts can also be crosstabbed like other elements. For instance, completion date by country:</p> <p>Date and time values often arise in context of more advanced analytics goals, such as intervals, regimens, etc. Protobi has many capabilities for time calculations not yet written here. Contact <a href="mailto:support@protobi.com">support@protobi.com</a> and we'll help you get setup for your case. </p>
Date
Status
Published
Draft
Slug
edit
Thumbnail
Categories
Manage
Release
Features
Datasets
Surveys
Tips
NAMCS
Applications
Crosstab
Tutorial
Design
Concepts
Segmentation
Examples
Blog Test Category
Delete
Convert to MD