Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Charlene
Frequent Visitor

Capabilities object - selfFilter

I see in capabilities object properties your able to set a selfFilter.

"selfFilter": {
"type": {
"filter": {
"selfFilter": true
}
}
}

I cant see any more details on this, as to how it works and how to implement it once its been set in capabilities.

Can anyone direct me to examples and details on this please?

 

I'm trying to filter my custom visual and not just the other visuals and thought this may be the correct solution, but struggling to get more details on how it works.

If anyone can please assist and advise?

Thank you

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi  @Charlene ,

Please review the following links, hope they can help you.

Apply JSON Filter to own custom visual

With help of a fellow forum member I got it to work the way I want. You need to do the following to have your visual filter itself AND others visuals:

capabilities.json (general)

            "properties": {
                "filter": {
                    "type": {
                        "filter": true
                    }
                },
                "selfFilter": {
                    "type": {
                       "filter": {
                          "selfFilter": true
                       }
                    }
                 }
            }

 

ApplyJsonFilter call(s)

    this._visualHost.applyJsonFilter(
      filterList,
      "general",
      "selfFilter",
      powerbi.FilterAction.merge
    );
    this._visualHost.applyJsonFilter(
      filterList,
      "general",
      "filter",
      powerbi.FilterAction.merge
    );

schema.capabilities.json

Trying to filter data in custom visual

Best Regards

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

Thank you ‌‌

I added the above and still having an issue that its still not fitering correctly - Maybe you can advise?

Added the above property filter settings (capabilities) & the applyJsonFilter call

Strangly I now have that if I include the 'general' filter & its related applyJsonFilter call then it doesnt work at all and no fitering gets triggered

 

"properties": {
"filter": {
"type": {
"filter": true
}
},


However if I remove the above and only have the 'selfFilter' (with of course the applicable applyJsonFilter)  then it seems to filter my custom visual but the other powerBi visuals dont get filtered.

 

"selfFilter": {
"type": {
"filter": {
"selfFilter": true
}
}
}


Any ideas why the 'general' prorperies filter will cause all filtering not to work?

Thank you, I appreciate any suggestions and examples you can assist me with

PS: Did look at the linked examples and cant see anything out of the ordinary that id different and why mine isnt working

UPDATE: (2)

So although I got both filters to be active in capabilities, the selfFilter applyJsonFilter call works but the general filter doesnt seem to do anything and causes more problems (causing my other functionality to intimitantly not work correctly). When I remove the general filter and only use the selfFilter it seems to work correctly. So offically giving up on including the general filter in capabilities.

 

So as result to get my filters to work I needed to do the following:

1) Ensure my selectionArray contain the correct data (update and remove selections as click event triggered on my visaul) and this is passed to applyJsonFilter : This works and my custom visual now filters correctly (when click item on my cutom visual to filter by). My custom visaul also filters correctly if filter was triggered by another visaul

2) Now needed to add functionality to update the selection in my array if a new selection was triggered my an other visaul. Aka select item on my visaul then click other visaul with new selection or de-selection. This is also working correctly. My selectionArray update to new selection or clears array if de-selection.

 

Biggest problem now is that the persistantFilter on the powerBi toolbar doesnt seem to trigger / reflect corrrectly. If click my visual it has the correct filter data. However if I click another visaul then the persistantFilter doesnt trigger and reflect that there are active filters

 

Any suggestions to either get other visauls filter selection to reflect in the persistnatFilter or oterwise how do I completly disable / hide this button in my code

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.