Jump to content

Gaia Paolini

Spotfire Team
  • Posts

    761
  • Joined

  • Last visited

  • Days Won

    9

Community Answers

  1. Gaia Paolini's post in I want to get the last value of a particular group through the calculated column. was marked as the answer   
    Your original formula threw an error for me, I think because Last does not work after Over.
    Can you try this:
    ValueForMax([Production Time],[Target Value]) over ([Product ID],[Process Name])
  2. Gaia Paolini's post in Add different columns representing similar data on different days to x-axis and create a line chart was marked as the answer   
    I think it can be done, I put together a Spotfire dxp to exemplify. It appears a lot of ticks, but it is easy once you have done it a few times.
    I unpivoted the data in the data canvas I added a [Day] calculated column, to extract the numbers from the content of the column, as: Integer(RXExtract([Category],'\d+',1))I changed the colour of the marking to yellow: top menu > File>Document Properties > Markings I created a line chart. I changed its appearance so marking would appear as a separate colour: right click on plot > Properties > Appearance> Use separate color for marked items. I coloured the chart by [batch] but kept all the colours grey: right click on plot > Properties > Colors. I changed the Y limits to 60 and 105: right click on plot > Properties > Y Axis> Range. I added a calculated column [Avg_value] to represent the average: top menu > Data > Column properties > Insert:  Avg([Value]) over ([Category])In the plot, I added a line representing this column: right click on plot > Properties > Lines & curves > Add > Line from column values. I adjusted line thickness in both normal lines and average. When you click on a line, it is marked in yellow.

  3. Gaia Paolini's post in Static Sub-totals when filtering a crosstable was marked as the answer   
    The only way I could find to see only the subset of filtered data and to preserve the percentages was to define a calculated column to represent your total count. Calculated columns do not react to filters.
    So if you change your expression to this, where [TotalTotal] = Count() was your new calculated column
    Count() / Max([TotalTotal]) as [%Total]... then it should work. I had to add Max() as it wants an aggregation.
    You could try using a dropdown selection of the Body System and then setting a rule in Show/Hide items, but I could only make it work if only one Body System is selected each time.
  4. Gaia Paolini's post in How to perform operations over data from different rows and create a plot? was marked as the answer   
    From what you said, I would try to apply a pivot transformation to your data, then you can create as many column combinations in the plot as you need.
    I have slightly changed your sample data (the values for A were all 1, and the X values were repeated). See attached dxp.
    Basically I created a pivot table by adding a new data table (press + then choose 'Other' then choose the existing data table) so as not to overwrite the original, then applied a pivot transformation so that the resulting table looked like this (right):
    Then I plotted the pivoted table using as columns: Y_A, Y_B then Y_A-Y_B, Y_A+Y_B resulting in this plot:

  5. Gaia Paolini's post in Filtered on a single chart was marked as the answer   
    you can also set up charts to 'ignore current filtering' if you do not want any filtering to be applied to those. Untick all the boxes under 'Limit data using filtering' in the Properties > Data tab.
  6. Gaia Paolini's post in Filter table to get one record from each group was marked as the answer   
    Try this approach:
    On top menu:
    Data > Column Properties > select SOURCE 
    Choose Sort Order tab.
    Choose Custom Sort Order and configure the desired order
    press OK
    Now define the calculated column [sourceRank] as
    DenseRank([sOURCE],Concatenate([FORM],[uWI]))
    The filter can then be applied to [sourceRank]=1.
  7. Gaia Paolini's post in Select Column to send to data function from a document property was marked as the answer   
    If you only want to select a single column (say defined via document property ColumnToSelect)
    then when you are specifying the parameters to your data table, choose Expression as Input handler
    and type the following custom expression in the expression editor:
    [iris].[${ColumnToSelect}]
    in this example I am using a data table called iris, change the name to yours but make sure it is also selected as a data table
    at the top of your expression (see TOP picture) otherwise Spotfire will complain that it does not find the table.
    If you want to send multiple columns (defined via a multi-selection document property ColumnsToSelect)
    then use the following expression: (see SECOND picture)
    $map("[iris].[${ColumnsToSelect}]", ",")
    which is actually typed for you automatically if you go and select the document property and right click on it 
    on the Available properties for column list above the expression editor.
  8. Gaia Paolini's post in How can use IronPython to create a new TagsColumn? was marked as the answer   
    You can create a new Tags Column from Iron Python, for example:
    # Copyright © 2022. TIBCO Software Inc. Licensed under TIBCO BSD-style license.from Spotfire.Dxp.Data import TagsColumnnewTagColumnName='newTag'cols = Document.Data.Tables["iris"].ColumnsnewTagColumn=cols.AddTagsColumn(newTagColumnName,['yes','no']);In this script I am creating a new Tags Column called 'newTag' in the 'iris' data table, with potential values of 'yes' and 'no'.
    The column will be created and you can visualize it just like any column. Also you can go up to the top menu and choose View >Tags to see it. It is initially all 'Untagged'.
    You can use Iron Python to set it as well. In the example below I am getting the marked rows as input and set the tag to 'yes' for those rows.
    # Copyright © 2022. TIBCO Software Inc. Licensed under TIBCO BSD-style license.from Spotfire.Dxp.Data import DataColumn, TagsColumn, IndexSet #Marked rows on the source tabledataSelection = Document.Data.Markings['Marking'] #the default marking schemedataTable = Document.Data.Tables['iris'] #my data tablemarkedRowSelection=dataSelection.GetSelection(dataTable) #Get handle to the required column and cast it to a tagcolumnmyTagColumn = dataTable.Columns.Item["newTag"].As[TagsColumn]() #Loop through the tag list and add the tagged/nontagged rowstags = myTagColumn.TagValuesfor t in tags: if t == 'yes': myTagColumn.Tag(t, markedRowSelection)
  9. Gaia Paolini's post in How to add points to a Scatter Plot that represent the average of displayed points? was marked as the answer   
    if you are happy with a trellised plot then you could try something like this? I added a line representing the average and it is different for each trellis panel.
  10. Gaia Paolini's post in #DrSpotfire String value in a column are not visible in spotfire data table, I tried to change the formatting of the column to string still, getting a blank cell for string values. Can someone please help me? was marked as the answer   
    Hi Rashmi, normally there is a warning (a small yellow sign appearing top-right of the page) that there were some inconsistencies and some data might not have loaded successfully.
  11. Gaia Paolini's post in How to plot overdue tasks per month by comparing due date to completion date? was marked as the answer   
    From your question, I am not sure whether you want to check one month at a time, or you want to produce a table with all the different reference dates, like you showed in the screenshot.
    In both cases, I suggest importing the reference dates table as a separate table, we only need one column (Reference Dates). 
    Say we call the table 'Reference Table' and your original table is 'Data'.
    A - if you want to check one month at a time:
    1 - create a drop down list in a text area, that shows the Unique Values in Column from table Reference Table and column Reference Dates. Assign it to a new string document property called refDate.
    2 - create a calculated column in your Data table, called [overdue] as
     ([Completion_Date] is null or [Completion_Date]>=DateTime('${refDate}')) and ([Due Date]<DateTime('${refDate}'))
    3 - create a new textarea with a calculated value of Sum(Integer([overdue])) over your Data table.
    This will show you the number of overdue tasks for each selected reference date individually. 
    B - if you want to check all reference dates in one go:
    Here it would probably be best to use a data function. I am showing a possible example of a Python script (note that the indentation is lost in the copy/paste).
    Input parameters: data_df is 'Data', ref_dates_df is 'Reference Table'. Both are of type Table.
    Output parameters: ref_dates_output is a new reference table with the calculated overdue column.
    import numpy as np
    import pandas as pd
    #allow for different column names
    reference_date_column='Reference Dates'
    due_date_column='Due Date'
    complete_date_column='Completion_Date'
    #change data type to datetime if they are strings
    if ref_dates_df[reference_date_column].dtype==np.dtype('O'):
      ref_dates_df[reference_date_column]=pd.to_datetime(ref_dates_df[reference_date_column])
    if data_df[complete_date_column].dtype==np.dtype('O'):
      data_df[complete_date_column]=pd.to_datetime(data_df[complete_date_column])
    if data_df[due_date_column].dtype==np.dtype('O'):
      data_df[due_date_column]=pd.to_datetime(data_df[due_date_column])
    #for each reference date, compute overdue items
    overdue=[]
    for refd in ref_dates_df[reference_date_column]:
      overdue_df=data_df.loc[((data_df[complete_date_column].isnull()) | (data_df[complete_date_column]>=refd)) & (data_df[due_date_column]<refd)]
      overdue.append(overdue_df.shape[0])
       
    #add column
    ref_dates_output=ref_dates_df.copy()
    ref_dates_output['calculated_overdue']=overdue
  12. Gaia Paolini's post in Punctual to interval data interconnection was marked as the answer   
    I replied to a similar question a few months ago, got no feedback so I don't know if and which solution worked.
    https://community.spotfire.com/s/question/0D54z00007pNO8OCAW/how-to-calculate-pairwise-euclidean-distances-between-datasets-on-heatmap
    You could do it via a data function (R or Python) or you could try purely in Spotfire.
    The Spotfire method only involves Spotfire joins and calculated columns. It might generate a lot of rows initially.
    The idea is to do a complete cartesian join of the two tables and then filter in only the depths that are between top and bottom.
    1 - via the data canvas, add a transformation = Calculate New Column to your table 1, called e.g. [forJoin] with a single value, any value, e.g. 1. This column will be used for the join
    1 - do the same for table2
    3 - create a new table based on your original table 1.
     go to + and choose 'Other' then select the original data table: choose 'add as new data table'.
     this creates a new table based on the original data. 
    4- add columns to this table, coming from table 2. Join on [forJoin], join settings=Full Outer Join. This creates all the row combinations.
     save the joined table as 'always new table', as it would refresh every time you update the original table.
    5- still on the data canvas, add a filter as ([depth]>=[top]) and ([depth]<=[bottom])
     this will keep only the rows with depth between top and bottom.
  13. Gaia Paolini's post in How to use IronPython to import data? was marked as the answer   
    Assuming that you have already a data table in Spotfire containing data that has the same structure as what you want to load, you could use something like this, where "table" is an input parameter of type Data Table (your target table, pre-existing).
    If your files are all of different structures instead, you will need to also create the data table on the fly. https://community.spotfire.com/s/article/IronPython-script-to-load-an-In-memory-csv-file-in-TIBCO-Spotfire
    # Copyright © 2022. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    # Replace tables from files
    import clr
    import Spotfire.Dxp.Data.DataTable
    from Spotfire.Dxp.Data import *
    clr.AddReference("System.Windows.Forms")
    from System.Windows.Forms import OpenFileDialog
    from Spotfire.Dxp.Data import *
    myDataManager = Document.Data
    d1 = OpenFileDialog()
    d1.Multiselect=True #lets you select more than one file
    d1.InitialDirectory='C:\MyData'  #the folder containing your source data files
    d1.ShowDialog()
    files=d1.FileNames
    #lazy workaround: replace data with first file then add the other selected files
    ds=myDataManager.CreateFileDataSource(files[0])
    table.ReplaceData(ds)
    for ff in files[1:]:
    ds=myDataManager.CreateFileDataSource(ff)
    settings = AddRowsSettings(table,ds)
    table.AddRows(ds,settings)
×
×
  • Create New...