cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Custom Slicer Loses Value When Toggling Visibility

I have a custom slicer I wrote that filters dates.  It's pretty basic, you just give it a date field and it lets you filter the report down to a single date.  The issue I'm having with it is if I select a date, the report filters down correctly.  If I then hide the visual it loses the selection and the filter is gone.

 

I'm having trouble finding documentation on what's happening behind the scenes when it's hidden.  Can anyone give me some insights into what's going on and if there is some type of special handling for this secenario?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Custom Slicer Loses Value When Toggling Visibility

Hi @cboneill0099 ,

 

Seems it act like a visual interaction instead of filter, please try to added the Advanced Filter API based on this similar thread: https://community.powerbi.com/t5/Developer/Custom-Slicer-Selection-Issue/td-p/371992

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Community Support
Community Support

Re: Custom Slicer Loses Value When Toggling Visibility

Hi @cboneill0099 ,

 

Seems it act like a visual interaction instead of filter, please try to added the Advanced Filter API based on this similar thread: https://community.powerbi.com/t5/Developer/Custom-Slicer-Selection-Issue/td-p/371992

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Frequent Visitor

Re: Custom Slicer Loses Value When Toggling Visibility

Thank you.  I'll give that a shot.

Highlighted
Frequent Visitor

Re: Custom Slicer Loses Value When Toggling Visibility

I attempted to use the filtering API and it solved half of my problem.  Now, when I hide the visual the filter does not go away, but when I make the visual visable again, the filter gets lost.  Is there something I should be doing to persist the filter behind the scenes and reload it when making the visual visable again?

 

Here is my code in the update method:

        let filterTarget: IFilterColumnTarget = {
            table: categories.source.queryName.substr(0, categories.source.queryName.indexOf('.')),
            column: categories.source.displayName
        };
        
        const basicFilter: IBasicFilter = {
            $schema: "http://powerbi.com/product/schema#basic",
            // target: {
            //     table:"Date",
            //     column:"CalendarYear"
            // },
            target: filterTarget,
            operator: "In",
            values: [dateSelectionValue], //[2019],
            filterType: FilterType.Basic
        }

        this.visualHost.applyJsonFilter(basicFilter, "general", "filter", FilterAction.merge);

 

This is what I added to the capabilities file:

"general": {
            "displayName": "General",
            "displayNameKey": "formattingGeneral",
            "properties": {
                "filter": {
                    "type": {
                        "filter": true
                    }
                },
                "selfFilter": {
                    "type": {
                        "filter": {
                            "selfFilter": true
                        }
                    }
                }
            }
        }

 

 

Thank you

Highlighted
Frequent Visitor

Re: Custom Slicer Loses Value When Toggling Visibility

There was an error in my code causing the filter to get lost.  The above solution worked for me.

 

Thank you.

Helpful resources

Announcements
June 2020 Community Highlights

June 2020 Community Highlights

Featured community members, changes to the Community, and more! Read up on recent Power BI community news.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors