Jump to content

Delete Multiple/All Filters in a Report


barchiel33

Recommended Posts

Hello All,

I was wondering if there was a way to delete (not hide or clear) multiple filters for a data table in a report? I know that it's possible to delete individual filters by setting AutoConfigFilter to manual and it's possible to start with no filters by setting the report default to manual, but I can't seem to find a way to remove filters in mass from a report that started as AutoConfigFitler. I've tried some stuff with Ironpython but just ended up crashing Spotfire when I tried removing a FilterCollection from a FilteringScheme. When I tried iterating over the filters in a FilterCollection and using FilterCollection.Remove(filter), it didn't seem to do anything.

Thanks in advance!

Link to comment
Share on other sites

Hi,

To better understand your request, you want to start a dashboard with no filters (as you have set the AutoConfigFilter parameter to manual).
But, for existing dashboards, they do have the 'full set' of filters still applied to them and you want to delete them? Not one by one, but all in one go?

I've found this iron python code, but I'm not entirely sure it fits your request:

Kind regards,

David

Link to comment
Share on other sites

Unfortunately that article doesn't work for what I'm trying to do. I have a report with filters already created for every column due to the automatic creation, I want to delete a large number of them. The code shown only removes them from groups within the filter scheme organization.

Link to comment
Share on other sites

Hi,

I have found a script online and tweaked a little bit into this:

myPanel = Document.ActivePageReference.FilterPanel;
myGroup = myPanel.TableGroups[0];

colNameToDelete = 'z'
for filteringScheme in Document.FilteringSchemes:
	filterCollection = filteringScheme[table]

for filter in filterCollection:
	if filter.Name != colNameToDelete:
		myGroup.Remove(filter)
		filterCollection.Remove(filter )

This will delete all filters in the Filter Panel for a given data table (which you have to add as parameter (see screenshot below)), except for the 'z' column. As I didn't have any 'z' column, all filters from the specified data table were deleted.

image.thumb.png.b9d68a6efd577b28c2a284fb1ec6e7ae.png

You can put this script behind a button or use it at your convenience from the Properties menu of course.

Kind regards,

David

 

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...