How to create a derived field for time


Well basically that’s my question. I was looking at this thread and I have a similar problem. I need to show some fields as time fields but I would like to know how can I use derived fields for that.


Well it depends on what is the format of the field stored that you want to use as a time field. Time data is handled by ChartFactor Toolkit in the following format: YYYY-MM-DD HH:mm:ss.SSS. So to use a derived field you need to convert your field data to that format. So for example let’s say you have a field callled “year” that is an integer that you want to use as time:

let eventYear = {
    'name': 'event_year',
    'label': 'Event Year',
    'type': 'TIME',
    'function': year => `${year}-01-01 00:00:00`,
    'timestampGranularity': 'YEAR',
    'dependencies': ['year']

The important part here is the function property and how it expects the data as it is and returns the formated data as time.

Can't add a Time Slider to Studio
Can't add a Time Slider to Studio

For some reason is not working, I had exactly what you specified just changing the function to this:

var rsDateDerived = {
    'name': 'rs_date_derived',
    'label': 'Release Date Derived',
    'type': 'TIME',
    'function': function (date) {
       var parts = date.split(',')
       return parts[1] + '-' parts[2] + '-01 00:00:00';
    'timestampGranularity': 'YEAR',
    'dependencies': ['rs_date']

Then I added it to the metadata and when I tried to use it it errors that rs_date_derived was not found in the fields. Do i have to use the same name of the field it depends on or does it has certain convention?


No, you can use any name you want. Make sure that in your metadata you are using rs_date_derived too as the name of the field:

'your_source': {
  'fields': {
     'rs_date_derived': rsDateDerived


The only drawback as I see from using derived fields is that you cannot apply them as filters. I saw the warning in the developers tools, so I kind of come up with the idea of applying the filters my self using the IM api.


Thanks @eduardo , this fixed the issue, I didn’t notice that I had a different name in my metadata.


@sandip Actually that was a debt we had for derived fields that was solved in the latest release. Since filters were not supported by this type of fields, some developers coded some workarounds or the end users simply had the equivalent chart for the dependency.

In the latest version we introduced the property reverse which works exactly as the property function in the derived fields. Only that reverse takes as parameter the derived value. The user then can translate back the value to its original. For more info take a look here