Trouble using Computed Column as Labels on Report maps

I’m trying to use a computed column in a Report for labelling features on a map.

  1. The Report is based on a “Patrol Query” which generates a table and a map of patrol tracks.

  2. I created the Computed Column by going to Reports > Outline > Data Sets > right click on the relevant Query > Edit > Computed Columns.

  3. The Computed Column is a substring of the default style Patrol ID (in my case e.g. Atewa_000123), and the expression I used is row[“Patrol ID”].substring(9,12) (and I confirmed that this gives the desired result of the final three digits of the Patrol ID by viewing the query as a table and putting this expression in a blank field). Computed Column name is PatrolNum.

  4. Going to the Map > MapLayers > Style, the Computed Column appears as expected in the drop down list of possible Label values.

  5. But when I run the report I get a (long) error message basically saying “Could not find ‘PatrolNum’ in the FeatureType (smart:null)” and then lists the available options which are just the standard columns for a patrol query.

Is there another correct way to use a computed column as a label that I’m overlooking?

Many thanks

Jeremy

PS, can anyone explain why I had to use substring(from 9, to 12) in order to get the 10th, 11th and 12th characters of the patrol name? Substring(10,12) would seem more logical to me!

I don’t believe there is any way to use computed columns as Labels at the moment. I don’t think we ever considered this use case and we would need to see if it’s possible in BIRT to make it work like that, which can be tricky with computed columns being dynamic etc, but it might be possible. I will create a new potential feature item in Assembla for this,
https://app.assembla.com/spaces/smart-cs/tickets/3477-allow-computed-columns-to-be-used-as-label-in-report-maps/details

Feel free to bug your SMART contacts to make this feature a priority if it’s important to you! :slight_smile:

Why you use substring(9,12) instead of 10,12 is just the definition of the function you are using, which can be found here: JavaScript String substring() Method

The first number is “Start position. First character is at index 0”
Programmers sometimes like 0 to be the first character and other times 1, so it is always a toss-up which to use, but for this particular function, the letter indexes start at 0.

the second number in the function is: “End position (up to, but not including).” so that is why you put 12 and not 11.

1 Like

Thanks Jeff. Shame that’s not possible! Thanks for making the suggestion.
Thanks also for the insight into programmer culture. Gonna start teaching my kids to count from zero see how that goes lol