Forum Discussion
Custom Slicer Loses Value When Toggling Visibility
- 6 years ago
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,
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,
- cboneill00996 years ago
Helper I
Thank you. I'll give that a shot.
- cboneill00996 years ago
Helper I
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
- cboneill00996 years ago
Helper I
There was an error in my code causing the filter to get lost. The above solution worked for me.
Thank you.