Spotfire: Changing Time Hierarchy using Multiple Date Columns

Posted on Updated on

When using multiple date columns (switched using property control) on a particular axis, we lose the ability to change the time dimension of the date selected. In order to overcome this issue, we can add a Time Hierarchy property control (a slider) and use it to alter the date column’s time hierarchy.

We start off by building a property control for changing date column. An important note here is to provide the Value as exact literals of the column name which you want to use against a Display Name. 

Change_Time_Hierarchy_3

Then we create a TimeHierarchy slider control to navigate across three dimensions – Year, Quarter and Month.

Change_Time_Hierarchy_4

And apply the below custom expression on the date column.

Change_Time_Hierarchy_5

This customization allows us to change the Time Hierarchy for Date columns. Below is a view of quarterly Sales (by Order Date)

Change_Time_Hierarchy_2

And a monthly Sales view (using Dispatch Date)

Change_Time_Hierarchy_1

K-Means Clustering using Spotfire

Posted on Updated on

To perform K-Means clustering in Spotfire, we need an appropriate line chart on which the clustering calculation could be performed.

Below we are using a simple line chart with Sales on Y-axis (a single column and not a custom expression with multiple columns) and Order Date on X-axis.

K-Means_Cluster_1

The Euclidean distance is used to perform the clustering with maximum number of clusters to be 9.

K-Means_3

Here is a segmented view of similar product sub-categories which fall in clusters depending on their sales performance.

K-Means_Cluster_2

Spotfire: Passing value from HTML/JavaScript to Document Property

Posted on Updated on

Reference snippet to pass a radio button value into Spotfire context, that is into a Document Property.



<FORM><B>Select date for filtering:</B>
<P>
<INPUT id=”pack1″
onclick=”document.getElementById(‘145de349837d49f493cc9ec23743b05f’).value=document.getElementById(‘pack1’).value”
value=”N” CHECKED type=radio name=pack1>
Date 1<BR>
<INPUT id=”pack2″
onclick=”document.getElementById(‘145de349837d49f493cc9ec23743b05f’).value=document.getElementById(‘pack2’).value”
value=”Y” type=radio name=pack1>Date 2
</FORM>
</P>


HTML to Document Property

Link to sample Spotfire analyses

R Shiny – Histogram

Posted on

Using Shiny Package in R to develop a Histogram with binning.

R_Shiny_Histogram

Reference:

Histogram – RStudio Shiny

Going beyond base Tableau – Unofficial Add-ons

Posted on Updated on

Advanced data visualization tools such as Tableau and Spotfire bundle capabilities such as Table calculations and Custom expressions respectively and make new dimensions of viewing data possible. Further, interactivity and customization which could be brought into dashboards with the use of parameters (in Tableau) and property controls (in Spotfire) set apart these visual analytic products from conventional BI query and analysis tools.

However, apart from out-of-the-box functionality, more could be achieved using these tools with some minor tweaks. One such example is to use phpGrid in a webpage (as part of the Tableau dashboard) as a user interface to show dynamic views depending on the data entered on the grid.

Below is a simple gantt chart which has parameters to filter data. Interactivity is limited to filtering data depending on the filters which only work on the data from the source file.

Gantt_Chart_1

However, there are a couple of ways we could update the data into a database with these parameters. First is to use a phpgrid to interact with the database using the refresh button action. And another method is to use the GET method (to pass parameters as part of the URL) using the dashboard webpage.

By Ryan Robitaille

http://ryrobes.com/tableau/tableau-phpgrid-an-almost-instant-gratification-data-entry-tool/

By Russell Christopher

http://tableaulove.tumblr.com/post/27627548817/another-method-to-update-data-from-inside-tableau

Getting column values from filtered data selection

Posted on Updated on

Reference snippet for fetching the values from a particular column after filtering is applied to the data table.

import Spotfire.Dxp.Data.DataTable
from Spotfire.Dxp.Data import *
from Spotfire.Dxp.Data import DataValueCursor

dataTable = Document.ActiveDataTableReference
rows = Document.ActiveFilteringSelectionReference.GetSelection(dataTable).AsIndexSet()

for row in rows:
for column in dataTable.Columns:
if (column.Name == "colName"):
print (column.RowValues.GetFormattedValue(row))