Jump to content

Dinamically change the column name in a custom expression using $map in Spotfire

Roberto Sichera

Recommended Posts

I have a property that contains a list of column names and I want to create a custom expression using the $map function, something like this

$map("Sum(${myproperty}) as [${myproperty}]", ",")

However, I would like to change the column names dinamically when they contain a given string.

I have tried the following, which however doesn't work as it returns the expression between []

$map("Sum(${myproperty}) as [if(Find('string',${myproperty}),'new name', 'old name')]"), ",")

I have also tried the following, but it seems that $map() does not accept Concatenate()

$map(Concatenate("Sum(${myproperty}) as [",

if(Find('string',${myproperty}),'new name', 'old name'), "]"),


Is it possible to realize what I am trying to do in Spotfire

Link to comment
Share on other sites

myproperty contains a list of column names, e.g Col1, Col2, Col3


As  I trigger an action through a button, I managed to solve my problem by creating a new property containing the new column names and change this property by an IronPython script.


In this way I can use the custom expression:$map("Sum(${myproperty}) as [${myotherproperty}]", ",")


However, I wonder if it would be possible to do the same thing without using an IronPython script.

Link to comment
Share on other sites

I am guessing this document property containing the list of string names is of type stringlist (otherwise, if it is already a comma separated string, I don't think you need $map).

I am not sure where you want to put this custom expression, so I am creating a calculated column with it. In the attached example there is a document property called myprop that is a stringlist, populated via a multi-select choice on the left of the page.

A calculated column called test1 concatenates this stringlist into a comma separated string:


A calculated column called test2_withSubstitution does the same but adds a substitution (Cat to Dog):


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...