All posts by Admin

Style cross table and data table with Javascript

With this small Javascript trick you can style a cross table and a data table, once activated it overrides the default style sheet. You can change the background color, font color or the font style and size. This works in the client and the webplayer.

css_data_table css_cross_table

1. Create a TextArea and edit it as HTML.
2. Add the following javascript.

Note: the page your report opens first should contain this Javascript.

 

IronPython script to clear properties

This script clears other properties when selecting/changing a property, so for instance if a user clicks on a propery listbox other property listboxes will be cleared.

How to use:
When you create a new property press the script button and add the script above. Next add a script parameter ‘propertyNames’ as a string and set the properties you want to clear.
In the script parameter ‘propertyNames’ you can add the names of one or multiple properties to clear. If you use multiple names separate them with a comma.

 

Information link on SAP HANA view with input parameter (aka placeholder)

Information links on SAP HANA views work pretty well until you have a HANA view that requires input parameters. The solution below is more a hack but it works.

For example this would be your default query:

But the HANA view requires the following input parameters ‘HANA_year’ and ‘HANA_month’. There are two things you need to do do:

  1. Remove the table alias every where, in this case ‘A1’
  2. Add after the table,  where the alias reference is, the placeholder code.

In the end your query should look like this:

Transform data with a start and finish timestamp to days per week

Your data looks like this and you need to report how many days an employee has worked.
time_dataset
So if ‘person 1’ starts at the first of January you would expect expect according to the calendar (2015) that this person worked 2 days in the first week of January.
time_cal

Note: This example only works with a fixed date range for the columns which will be unpivoted, these columns will be created at step 3.

  1. Create some flexible properties.
    time_properties
  2. Add the start week property to your data table and save it as ‘start date‘.
  3. Add for every week in the year a column and increase the weeks like w0, w1, w2, w.. This formula generates a start week for every week in the year by increasing the start week.
    For column w0 the formula will be: For column w1 use the same formula but change the 0 to a 1.

  4. Add for every week in the year a column with the corresponding week number 0, 1, 2, .. This formula will calculate the number of days worked per week.
    For column 0 the formula will be: For column 1 use the same formula but change every w0 to w1.

The data table now looks like this:
time_table1

  1. Unpivot the data table to a new data table and add a column to calculate the start week based on the category. See column date in the screenshot below.

    time_unpivot

Automatically update Spotfire charts and tables in your PowerPoint

This example will show you how to link charts and tables as an image in your PowerPoint presentation and use the Spotfire Automation Services Job Builder to periodically update the charts and tables. Every time you open your PowerPoint, it will check if the image has been updated and show the updated image.

ppt_wow

  1. Save your report to the Spotfire library.
  2. Open the Automation Services Job Builder and create the following basic jobs:
    ppt_automationInclude everything you want to export in this job but set the location of the images to a drive the PowerPoint user has access to.
  3. Schedule your job, not going into the details on that but for more info read this.
  4. Open your PowerPoint (in this example Office 2010) and goto: insert -> picture.
  5. Select the image you want to add and then select ‘insert and link’.
    ppt_save2
    This will add the image and keep a reference to the location of the image.
  6. If you now run the Spotfire Job and reopen your PowerPoint you will see the changes (if your data has changed).

Include video in your analysis

This is a little javascript trick to add video in your analysis…but this only works in the webplayer.

html5_video

The javascript will inject the HTML5 video tag into your TextArea and will only be visible in the webplayer. Depending on the browser versions you need to add different versions of the video (see the two sources in the example below).

  1. Create a TextArea and edit it as HTML.
  2. Add the following content:
    It should look like this
    video_html
  3. Create a Javascript and add the following code:

Reminder: the video will only work in the webplayer.

Automatically start an IronPython script

Every time a user will navigate to this page an IronPyton script will be executed.
The trick is to add a drop-down list property and use some Javascript to trigger the change event of the drop-down list.

  1. Create a drop-down list property.
    open_dl
    1. Add a drop-down list property.
    2. Set a script for the property.
    3. Add some fake data, atleast 2 rows.
  2. Next add a Javascript to the HTML/text area.
    load_el
    4. Copy the ID of the spotfire element (you need this in the javascript).
    5. Add a new javascript and use the copied ID.
    6. Use the following javascript to do the trick:

String matching

The basic comparison if a field contains a value is very limited, regular expressions can be like magic if you know how to use it.

  • contains
  • starts with
  • ends with
  • exact match
      or
  • does not contain
  • contains multiple
      or
  • if a string starts with 2 numbers and has an underscore after that

Change the contents of a property depending on another propterty

In this example there is a date dimension property with the option to select quarter or month. By selecting quarter or month the list box below will change the values.

multiple2multiple1

This can be done by:

  1. Create a drop down list, create fixed values with a display name and a value. The value should be equal to the column name you want to read the values from.
    The name of the property is ‘PropertyDateDimension’.
    multiple4
  2. Add a calculated column to your table and use the following formula, lets call it ‘dimension’.
  3. Create a multiple select list box.
    multiple5

 

Use a multiple select list box to filter visualizations (or use in a calculated column)

For example you have a list box (multiple select) which contains multiple quarters.multiple_select1

By selecting one or multiple quarters the data table next to it has to be filtered.
multiple_select2

The trick is to switch the statement and use a regular expression because the user can select multiple items and the formula needs to be able to compare that. Go to you visualization properties and add the formula bolow to ‘Limit data using expression’.

or

Or if you want to show all when nothing is selected.