Customer Banners (Ads) - SpiceUp. AX and SpotfireX Disclaimer



If you find this site useful and you want to support, buy me a coffee   to keep this site alive and without ads.

Comments in custom expressions

Prior to Spotfire 10, it was  not possible to add comments or comment a line in custom expressions. For version of Spotfire >10, the only way I can think of is to wrap the expression with a case statement:

Spotfire >10
//this is a comment
sum([a]) as ["a custom expression"]

Example
// Cumulative oil production per well
Sum([Oil Production]) OVER Intersect([Well ID], AllPrevious([Year]))


Spotfire >10
syntax:
case  "the ignored expression must be valid" > "both expressions must return the same data type" then   valid data type result, but ignored 
else 
  your expression
end

Example:
case when "Returns the year and week for today's date as an integer (Year*100 + Week number). For example, the date 2005-10-13 will return 200541.">"" then 0 
else 
YearAndWeek(DateTimeNow())
end


Example 1: Expression that returns a string

expression without comment:

First(If(UniqueCount([ProjectName])=1,[ProjectName],Concatenate(UniqueCount([ProjectName])," projects selected")))

expression with comment:

case "This expression shows the full name when only one item is marked. Else it shows the item count" > "Author: Jose Leviaguirre"
else
  First(If(UniqueCount([ProjectName])=1,[ProjectName],Concatenate(UniqueCount([ProjectName])," projects selected")))
end

Example 2: Expression that returns a Date 

without comment:

Date(RXReplace([Origin of data],"(\\D*)(\\d{4})(\\d{2})(\\d{2})(.*)","$2-$3-$4","ig"))

with comments:

case 
when "extracts the date from a string of the form 'my_file_20020604.xls'" > "Date('2002-06-04')" then Date("never reached")
else 
Date(RXReplace([Origin of data],"(\\D*)(\\d{4})(\\d{2})(\\d{2})(.*)","$2-$3-$4","ig"))
end

Example 3: Expression that returns a number

without comment:

Sum([Oil Production]) OVER Intersect([Well ID], AllPrevious([Year]))

with comments:

case when "Cumulative oil production per well">"" then 0
else
  Sum([Oil Production]) OVER Intersect([Well ID], AllPrevious([Year]))
end




No comments: