Using Atelerix in Report Items
Atelerix lets you alter data for the purposes of the report. Common tasks are:
- Concatenating strings (combining them)
- Formatting numbers (setting the number of decimal places, adding commas, etc.)
- Formatting dates (setting the date and or time string)
- Rounding numbers (trimming numbers to a certain number of decimal places)
Concatenating (combining) Text (Strings)
Text may be combined by using the plus sign. Given the following data we can combine things in several ways.
| age (Age) | city (City) | height (Height) | state (State) |
|---|---|---|---|
| 31 | Portland | 1803.48274 | Oregon |
To combine Portland and Oregon with a comma:
> data.city.value + ', ' + data.state.value
'Portland, Oregon'
You can also combine the field name or alias with a value:
> data.city.alias + ': ' + data.city.value
'City: Portland'
Numbers can also be combined into a string:
> data.age.alias + ': ' + data.age.value
'Age: 31'
Formatting Numbers
Sometimes you want to round and also to format the number as a string. To do this you can use the text() function with the optional second parameter format. For all the nitty-gritty details about formatting see the Format Text section. (You can format dates too) Given the following data ( assume that the birthday field is a date ) let’s see how we can format some numbers.
| age (Age) | birthday (Birthday) | height (Height) |
|---|---|---|
| 31 | 6/1/1980 | 1803.4827 |
To format a number to have a certain number of decimal places:
> Text(data.height.value, '0.0')
1803.5
> Text(data.height.value, '0.000')
1803.483
or add a thousands separator:
> Text(data.height.value, '0,0.0')
1,803.5
Formatting Dates
Formatting a date is similar to Formatting Numbers. See all of the details in the Format Text section. But given the following data ( assume that the birthday field is a date ) let’s see how we can format some dates.
| age (Age) | birthday (Birthday) | height (Height) |
|---|---|---|
| 31 | 6/1/1980 | 1803.4827 |
Without a format, we get the full date string:
> Text(data.birthday.value)
6/1/1980 12:00:00 AM +00:00
We can extract just the year:
> Text(data.birthday.value, 'yyyy')
1980
(hint: you could convert that to a number using the number() function and then do math on it)
Or format it using hyphens:
> text(data.birthday.value, 'MM-dd-yyyy')
06-01-1980
You can even get the day of the week
> text(data.birthday.value, 'dddd')
Sunday
Rounding (trimming) Numbers
To round a number, atelerix provides the Number.Round. Given the following data in infomaptic, let’s create a few examples on how a number can be rounded.
| age (Age) | city (City) | height (Height) | state (State) |
|---|---|---|---|
| 31 | Portland | 1803.48274 | Oregon |
To round the person’s height to the nearest whole number we would use:
> number.round(data.height.value, 0)
1803
That rounds the height value to zero decimal places. If we wanted to round it to include just one decimal place:
> number.round(data.height.value, 1)
1803.5
Let’s say that the height is in mm, but we want it in inches and rounded to the nearest inch. There are 25.4 mm per inch, so we can just divide:
> number.round(data.height.value / 25.4, 0)
71