How to use the replace function formula in the report layout

If you need to replace certain text in your report, in a dynamic way, you can do so by using the math.eval function in the report.

To add this script to your report, you need to know how to make a copy of your report, and edit this copy in SiteAdmin > Reporting > Manage Reports > View (your report copy).

To edit or customize report you can read more here.

Replace

  • $math.eval( {expression} ? {value if true} : {default value} )

where

:  denotes 'OR' operator

? denotes 'then' operator

Example 1: 

$math.eval([SOS] == 0 ? 'False' : 'True')

This expression will replace the result of the variable SOS signal, from 0 to False. If the value is <> to 0, it will add the default result 'True'

Example 2

$math.eval([Ignition] == 1 ? 'On' : [Ignition] == 0 ? 'Off' : 'no signal' )

This expression will replace the result of the variable Ignition from 1 to 'On' or from 0 to 'Off'. If none of these values are found, the default assignment will be 'no signal'

Example 3

$math.eval([Distance] < 1000.0  ? 0 : $math.round([Distance]/[Speed],2) )

This expression will replace any value under 1000 for 0. Anything over 1000 will be rounded to 2 decimals.