Jump to content

Access dynamic column name from bar chart based on case statement in iron python

Brian Merrill

Recommended Posts

Hi All -

I have a bar chart where we are dynamically creating the rows based on column values and we need to filter the other visuals based on the selected markings. I know how to obtain the markings (i.e., using an approach as described here:https://community.spotfire.com/wiki/how-retrieve-data-marking-selection-usi...), however because we are using a case statement to create the groupings, when the markings are selected, it's not identifying the rows that are unique the the case statement, but rather returning all of the rows with any values used in the case statements (because the value are column based and not row based).

For example, I have multiple columns [Value A], [Value B], [Value C], etc. The rows may have values in various combinations of the columns A, B, and C (i.e., A, B, or B, C, or A, C, etc.). The categorical axis we created is following the approach of: sum(case when [Value A] > 0 then [Value A] else 0 end) as [Value A Sum], sum(case when [Value B] > 0 then [Value B] else 0 end) as [Value B Sum], sum(case when [Value C] > 0 then [Value C] else 0 end) as [Value C Sum]. This is effectively un-pivoting the columns we care about into rows (we cannot use the data table unpivot due to data volumes).

When one of the categories is selected (e.g., Value A Sum), the visual does not return only those rows where Value A > 0 but rather every row in the table that has any of the Values from A through C.

We only care that Value A was selected so that we can populate a dynamic limit filter in the other visuals so they match (i.e., setting the limit on the other visuals to be: [Value A] >0) when that category is selected. The problem is, I cannot figure out a way to access the column name for the visual that was selected in the marking. I have poured over the object model for the visual and markings and it seems like it's not accessible (or at least I don't see how). The problem I believe is because Spotfire captures the markings at the row level and not at the grouping level that the dynamic category associated.

Does anyone know how to extract or get the column name of the visual that is associated with a marking I was hoping it would be something like viz.ActiveMarkingSelectionReference.ColumnName. It's obviously not that easy, and any actions taken on the marking referent GetSelection only gives the rows related to the selection, but I don't see how to get that columnname from that. Any thoughts/suggestions are greatly appreciated.


Link to comment
Share on other sites

Hi Bmerrill,


We had a few Spotfire experts look at your question and we would like to ask you to submit a specific and reproducable example to help us understand your question and provide you with a useful answer. Could you please submit that Also please refer tohttps://community.spotfire.com/wiki/quick-tips-asking-community-questions and maybe consider rewriting your question following those suggestions.




Heleen Snelting, TIBCO

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...