0

I have the pie chart & need to create crosstable based on marking but it should connect marking with only one column & other columns in crosstable should show all the data from main table regardless of marking.

Attached image is better explanation of my question, please let me know if anyone can help.

Currently i am getting table like top right but I need cross table like bottom right. Question is explained in Excel format but I am solving this problem in spotfire

I tried using subsets , didn't work. Kind of stuck after that

Question image

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Apr 04 '23 at 04:16
  • I understand what you are asking. I think you need a small script to achieve that. Please confirm whether IronPython scripting, or TERR or Python data functions are available in your installation. – Gaia Paolini Apr 04 '23 at 08:06
  • Thanks @GaiaPaolini , I have TERR in my installation, could you please help me how to proceed with it ? – user21558490 Apr 07 '23 at 03:54

1 Answers1

0

The question, as I understand it, is how to extend the marking from students to their teachers.

Firstly, in order not to have to send the entire data table to the TERR script, define a calculated column [student_teachers] as:

UniqueConcatenate([teacher]) over ([student])

This will give you the list of teachers associated to every student.

Then you would create a new TERR data function, called e.g. markTeachers. The only input would be the data table with your students and teachers. You only need to send in the student_teachers column.

This table needs to be limited by the marking you are using to select your students. So the only data that enters the TERR script is the marked rows.

The TERR script is like this:

#Parameters:
#data the input data table, restricted to marked rows

if (nrow(data)>0) {
  tmp=paste(unique(data$student_teachers),collapse=', ')
  tmp=unique(strsplit(tmp,', ')[[1]])
  markedTeachers=paste(paste0('$',tmp,'$'),collapse=',')
} else {
  markedTeachers=''
}

The variable markedTeachers outputs to a document property, say you call it also markedTeachers.

There are a few gyrations that might look odd:

1 - you might have selected more than one student. Therefore the variable tmp is first filled with the concatenation of all marked students, then trimmed and turned back into a vector, containing the unique teachers' list.

2 - there might be teacher names that are one the substring of another. If you don't put some markers to isolate a complete name, you might collect more teachers than you wanted. That is why I surrounded every teacher's name with $.

You can set this script to run automatically every time you change the marking.

In your cross table, you would use the following Limit data using expression:

Find(Concatenate('$',[teacher],'$'),'${markedTeachers}')>0

Again, I surround the teacher by $ so you don't accidentally find substrings of their names.

Gaia Paolini
  • 1,044
  • 1
  • 5
  • 4
  • This is great ! I'm quite new to TERR scripts, would it be possible for you to elaborate a bit including 1) 'type of script' while registering data function 2) how to add input parameter 'data' as my table 3) how to make output 'markedteachers' as document property 4) should crosstable be independent from colour marking and only dependent on data limiting from our output property? – user21558490 Apr 12 '23 at 18:06
  • I went through the script, it gives me output in crosstable but only first row is appearing. Do you have any idea what wrong I may have been doing here? – user21558490 Apr 13 '23 at 10:24
  • This might help https://community.tibco.com/s/article/A-Convenient-way-to-develop-an-R-Data-function-for-TIBCO-Spotfire-from-scratch. Type of script would be 'R Script - TIBCO Enterprise Runtime for R'. Adding input parameters is done via the Edit Parameters tab. Adding output parameters too. Crosstable should only depend on the limiting expression. – Gaia Paolini Apr 13 '23 at 15:19
  • This helped a lot! . I have a couple challenges 1) the crosstable is only showing first row of teachers, there's no data after that. Any idea where I went wrong? 2) my data has more than a million rows with atleast 50000 different teachers , so will this method affect any memory or calculation time since it's copying unique concatenate during This process? – user21558490 Apr 14 '23 at 13:44
  • This helped a lot! . I have a couple challenges 1) the crosstable is only showing first row of teachers, there's no data after that. Any idea where I went wrong? 2) my data has more than a million rows with atleast 50000 different teachers , so will this method affect any memory or calculation time since it's copying unique concatenate during This process? – user21558490 Apr 14 '23 at 13:45
  • I don't know why the cross table is showing the first row only. The example you gave worked for me. Regarding the data volumes, I guess it will impact the calculation times but not having the data to test I cannot know how much. The fact that only marked data is going into the script should help. Again, here context information helps. – Gaia Paolini Apr 14 '23 at 15:36