Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
Calling ISelectionManager.applySelectionFilter() from IVisual.update() sometimes causes an infinite update loop. I developed a custom slicer visual that will automatically choose the first or last item from the category. To do this, I call ISelectionManager.applySelectionFilter() form the first call IVisual.update() after the visual's constructor.
It doesn't happen every time, but is more likely when I publish a report to PBIOnline where the selected value is not the last or first value. Since all of the other visuals in the report are also set to the previous value, it causes the report to load, then reload to the newly seleted value. It seems to happen even when the visuals aren't configured to filter back on my custom slicer.
Anyone else run into this type of problem before? Any recommendations?
Solved! Go to Solution.
Slicer should not be affected by incoming selection but slicers will be filtered by other slicer as well.
Our recommendation is to call applyJsonFilter only for users actions.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
Recommendation is to stop calling applyFilter from update as each filter event will force PBI to call update method.
This is why infinity loop might appear.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
I think limiting the where and how applySelectionFilter() is called is key.
Durring the call to IVisual.update(), other visuals could have placed some or all of the selected items out of context. What is recommended for this case? I can see two options: (1) clear and make a new selection, or (2) take no action at all, leaving the selection in place.
Option 2 seems like it could leave the visual out of sync with the rest of the report. Since this visual is a slicer, it seems like it should have positive control at all times, and shouldn't have a "empty" state like a chart or grid. Recommendations are welcome...
Slicer should not be affected by incoming selection but slicers will be filtered by other slicer as well.
Our recommendation is to call applyJsonFilter only for users actions.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
I updated my code so that the call to ISelectionManager.applySelectionFilter() is called in only two cases.
1) When the user interacts with the slicer
2) On first load, and only if the current selection isn't the first or last (as dictated by the settings).
Origionally the code would call ISelectionManager.applySelectionFilter() when ever the contents of the slicer was updated programatically. In most cases the selection was the same. But, from what I can tell there isn't a chance for a feedback loop any more.
Such solution looks good.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |