Custom Expressions in JRS Report Builder

On the format results tab in JRS Report Builder there is a button to add a Custom Expression:

But what does it do and how do you use it ? 

The first thing to understand is that custom expressions are written in the language of the data source:

  • Data Warehouse: SQL
  • Lifecycle Query Engine: SPARQL

They are a great way of adding data to your report that isn't directly reportable. The easiest way to understand it is by example. Let's say you are reporting on requirements in DOORS Next and those requirements have two attributes: 

Let's say that in the report you want a sum of those attributes. Sure you could add a third custom attribute into the requirements module and then write some java script to populate it, but instead calculating it dynamically as part of the report is surprisingly easy. First create the report as normal and add the two custom attributes as columns. Then click Add Custom Expression to add another column that will be populated by your expression. 

In this case we will use a SPARQL expression that returns ValueA + ValueB. You can type the whole expression by hand if you wish - note that attributes must be wrapped in dollar signs. If you select an attribute and click the > button then it gets added to the expression automatically with the surrounding dollars - avoiding typos.


Your expression will be automatically wrapped in a BIND statement in the final SPARQL for the report so keep that in mind. You can validate the expression right here in the editor, and after applying it you can view the final result in the Advanced section.

Here is the result of this simple example:

And here is another one that compares two values and returns true if they are the same and false if they are not:

The table is then color coded based on that result:

Comments

Popular posts from this blog

New Quick Start: Method Composer

New Quick Starts for January