Tip of the Week

Setting Display Names for Expressions

The last couple tips have been more advanced uses of expressions, so I thought I would follow those with a basic, yet powerful example.  The first thing that came to mind was to explain how to rename an expression. Even though you can create powerful and complex expressions to alter how the data in your visualizations is displayed, there are also very simple expressions. In fact, expressions are used behind the scenes even when setting an axes value through the User Interface.

Suppose you want a Bar Chart that displays the Sum of ‘Electronics’ sold per ‘Store Location’. You can set the X-axis to use the ‘Store Location’ column and the Y-axis to use the ‘Electronics’ column and select Sum as the aggregation method. 

 


 
When you do that, you actually have created a basic expression.   You can view the expression dialog (by right clicking on the axis and selecting ‘Custom Expressions…’) to see the expression created:

 


 
Let’s say you do not want the axes to show Sum(Electronics). If you want to rename the output, you can use the ‘Display name:’ field , also in the expression dialog, to enter the display name,

 

 

This works great. However, let’s say you want the Bar Chart to have multiple columns on the y-axis (or any access for that matter). For example, the Bar Chart below shows both the Sum of Electronics and the Sum of Furniture on the Y-axis.

 

 

The expression used internally for this is:

 


 

With this, we cannot use the display name field to rename the output as there are multiple columns used .  If you want to rename the output expression for each column, you must use the As keyword inside your expression.

The As keyword will be paired with an expression and allow you to specify an output that is displayed anywhere that expression should be displayed (in all the axis selectors, tooltips, labels, etc…)

In this example, we can right click on any of the y-axis columns and select ‘Custom Expressions…’ and enter the following in the expression dialog:
 

 

You can see from the result below that anywhere the expression is used, in this case the Color By and y-Axis, the display names set from the As keyword are used.

 


 
When using the As keyword, if your desired display name is a single string without spaces, you can just enter it as is (i.e. As Electronics). However, if your display name is multiple strings, you need to enclose the name in brackets (i.e. As [Total Amount of Electronics Sold])

The As keyword as well as many other features are discussed in our SP 141 Computational Analytics class , which can be taken using one of our various delivery options: instructor-led onsite or public, blended training, or our bootcamp offering.

 

Comments

 

Setting Display Names for Expressions – Tip of the Week | Drakz Free Online Service said:

Pingback from  Setting Display Names for Expressions – Tip of the Week | Drakz Free Online Service

February 2, 2010 1:36 PM
 

William Bloomberg said:

Ah...  but let's say the custom espression is a calculation; for example: (Sum([Value]) / Sum([Value]) OVER (Previous([Axis.X]))) - 1.  This expression shows the percent change of the sum of the values from the previous period to this period, and should be shown as a percentage on a bar or line chart.  Instead, Spotfire shows the calculated value as a rounded number; therefore, 97.5% shows up as 1 and 2.6% shows up as 0.  Is there a way to format the values displayed when mousing over a section of a bar or point on a line?

February 3, 2010 1:23 PM
 

Expression setting | BelWin said:

Pingback from  Expression setting | BelWin

June 10, 2010 3:14 AM
 

Carly said:

Thanks a million! I was out of ideas after putting a comma between display names I wanted to use for multiple expessions, haha.

July 27, 2011 9:11 AM
 

Lily said:

This works perfectly for the Y axis but if I want to change the title of the X axis selector I am getting "The expression is not complete".

Also does anyone know how to dynamically change the title of the x axis selector.  For example in the above bar chart if that data is for the month of November only (the month filter is set to November) then I want the x axis selector to display November instead of Store Location.  Then if I change the filter to October I would want the title to dynamically change to say October.  Any ideas?

November 29, 2011 5:14 AM
 

uggkensington said:

http://www.uggkensingtons.org/

http://www.uggkensingtons.org/ugg-fox-fur-short-boots-5531-c-54.html | UGG Fox Fur Short Boots 5531

http://www.uggkensingtons.org/ugg-kensington-boots-5678-c-2.html | UGG Kensington Boots 5678

http://www.uggkensingtons.org/ugg-rainier-eskimo-boots-5189-c-85.html | UGG Rainier Eskimo Boots 5189

http://www.uggkensingtons.org/ugg-retro-cargo-boots-1895-c-3.html | UGG Retro Cargo Boots 1895

December 27, 2011 8:17 PM
 

uggskensingtonsale said:

www.uggskensingtonsale.org

www.uggskensingtonsale.orgugg-adirondack-boots-ii-c-6.html | UGG Adirondack Boots II

www.uggskensingtonsale.orgugg-adirondack-tall-boots-c-11.html | UGG Adirondack Tall Boots

www.uggskensingtonsale.orgugg-amberlee-boots-c-34.html | UGG Amberlee Boots

www.uggskensingtonsale.orgugg-annabelle-boots-c-35.html |

December 28, 2011 4:22 AM
 

uggretrocargosale said:

January 4, 2012 8:51 PM

Leave a Comment

(required) 
(optional)
(required) 
Submit

Syndication

Tags

Other Spotfire Blogs

Spotfire's interactive information visualization and analytic solutions give users a remarkable experience for quickly and easily querying data and reporting results for superior business intelligence. From portfolio management and customer retention programs to key processes such as CRM, marketing, research, bioinformatics, yield and asset management and design for manufacturing, enterprises around the world rely on Spotfire's business analytics software to improve operational performance.

©Copyright 2000-2011 TIBCO Software Inc | Privacy Policy | Terms of Use I Blog I Contact Us I Content Center