Reusable, Simple, & Easy ISO Week Calculation with TIBCO Spotfire
Blog: The Tibco Blog
ISO is an international standard for representation of dates and times. It was issued by the International Organization for Standardization (ISO) and was first published in 1988. The most important purpose of this standard is to provide an unambiguous and well-defined method of representing dates and times, in order to avoid misinterpretation of numeric representations of dates and times, particularly when data transfer happens between countries with different conventions for writing numeric dates and times.
ISO week date is defined in Wikipedia as leap week calendar system. A date is specified by the ISO week-numbering year in the format YYYY, a week number in the format ww prefixed by the letter ‘W’, and the weekday number, a digit d from 1 through 7, beginning with Monday and ending with Sunday.
ISO week in TIBCO Spotfire
There are multiple ways to calculate ISO week in TIBCO Spotfire. Two simple and easy ways to perform this calculation are through data functions and expression functions.
Since this standard has been out since 1988, there are lots of pre-existing solutions for this calculation. One of the CRAN packages that can easily help is ISOWeek. Click here for detailed documentation about the package.
The first step requires installing the package ISOweek using TERR tools:
Once the package is installed, you can either use data functions or expressions to perform the calculation. In this example, ISOweek function defined in the package is used to calculate ISO week
ISOweek would be one of the available functions. Please note that it is a column function and return type is string.
You can also create a data function, which can add a new column to existing data table. Here is sample data function that appends a column to existing data in Spotfire.
Both these methods result in additional column that is of type String.
Want to try these tips and our other tricks for yourself in TIBCO Spotfire? Start a free Spotfire trial today.
Comments (1)
Leave a Comment
You must be logged in to post a comment.
This does not produce the correct ISO week. ISO weeks start on Monday and end on Sunday. 7/24/2010 was a Saturday and 7/25/2010 was a Sunday. 7/25 should still be part of ISO week 29.