Skip to content

Attribute

This is the object that the .groupby() function expects as parameters. It represents the field used to aggregate a query.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// A normal attribute
var event = cf.Attribute('eventname')
                .limit(20)
                .sort('desc',metricObject)

// A time attribute
var saletime = cf.Attribute('saletime')
                    .sort('asc', 'saletime')
                    .func('DAY')
                    .limit(1000)

The Attribute constructor takes the name of the field that exists in the data engine and optionally a label.

Note

To update labels, the best practice is to use Custom Metadata. This avoids having to apply the same labels multiple times in your application.

  • limit() is the max number of results to be retrieved for that attribute

  • sort() takes two parameters, the first one is the sort order ('asc' or 'desc'), and the second is based on what is going to be sorted. It can be a Metric object or the string with the name of the same field, which will mean then that is going to be alphabetically sorted (or reverse alphabetically if is 'desc').

  • func() only applies to time attributes and it defines granularity of the data. The possible values are SECOND, MINUTE, HOUR, DAY, WEEK, MONTH and YEAR. If the data is in date format for example, we can not tell the object to use SECOND or MINUTE. This will be possible only data is in datetime format. If the data represents monthly events for example, there is no point in using DAY but MONTH or YEAR.