Tip of the Week

Marking Records using Property Controls

By default Property Controls cannot be attached to a marking selection. However, by combining Script Controls with Property Controls, we can create the desired functionality.

The first step is to create the Property Control(s). There are a variety of different ways to do this logic. First, you can use list box controls to show unique values in a column, and then mark the selected values. Or you can have one drop down to allow the user to select a column, and then a value to search for, and mark all rows where the specified column has the specified value.  We can even add multiple Property Controls to allow more complex logic (like if Col A = 3 and col B = ‘Boston’) and we can also use logical operators, like less than and greater than.

Assume our data table includes information about various cars, including make, model, sticker price, engine size, fuel economy, etc….  We want to create a Property Control that allows a user to specify a minimum sticker price. For this we can use an Input field control type, and have the control attach to a Document Property of type real (since the sticker price column, MSRP, is also a real).


We then need to create a Script Control which will mark the rows where the sticker price is greater than or equal to the value specified in the Property Control.  The Control will read in the minVal property created earlier as an input parameter.


 

 

The entire script is below:

from Spotfire.Dxp.Data import IndexSet
from Spotfire.Dxp.Data import RowSelection
from Spotfire.Dxp.Data import DataValueCursor
from Spotfire.Dxp.Data import DataSelection

rowCount = Document.ActiveDataTableReference.RowCount
rowsToInclude = IndexSet(rowCount,True)
rowsToMark = IndexSet(rowCount,False)

cursor1 = DataValueCursor.CreateFormatted(Document.ActiveDataTableReference.Columns["MSRP"])


for  row in  Document.ActiveDataTableReference.GetRows(rowsToInclude,cursor1):
   rowIndex = row.Index
   value1 = cursor1.CurrentValue
   if float(value1) >= float(minVal):
              rowsToMark.AddIndex(rowIndex)

Document.ActiveMarkingSelectionReference.SetSelection(RowSelection(rowsToMark), Document.ActiveDataTableReference)


When complete the functionality will look something like below:

.


 
Remember that using this capability is not limited to a single column, so you can add in as much complexity into your logic a you want.

If you are interested in learning more about the script listed above, or how to accomplish similar functionality, please consider taking our Script Controls training course.

We have also just added a new section on our Community called Analytics Exchange where community members can post a variety of assets, including Script Controls, Expressions, Analysis Files shared via the Web, S+ and R Scripts and Data Functions, and Sample Data Sets.  I am including the script above in the Script Controls section. Please remember to check out the Exchange to search for and find useful content, and also please feel free to post content you have created which you wish to share with others.

Comments

 

Tip of the Week said:

In general, Spotfire only reads data from underlying datasources and does not add, edit, delete or in

December 13, 2010 10:03 AM
 

Ling Xue said:

How do I use open circle instead of sold circle in the Scatter Plot above? I don't find a way to do that in Tipco Spotfire 3.1. Thanks, --Ling

ling.xue AT astrazeneca.com

August 11, 2011 2:45 PM
 

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:12 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 3:56 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit

Syndication

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