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
KennethWang
Frequent Visitor

applyJsonFilter triggers an update on the visual?

Hi,

 

Question pls. I have used Basic Filter API to influence other off-the-shelf and custom visuals. But somehow the visual triggers and update as well.

 

host.applyJsonFilter(filter, "general", "filter", powerbi.FilterAction.merge);

Is this normal and if it's possible to stop the update on the visual which triggers the filter?

 

Thanks.

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @KennethWang,

Pretty much any interaction with your visual is going to trigger its update method, so there might be a way of checking what's actually happening and planning for it.

When the update method runs, the options object exposes a type property, which provides a VisualUpdateType enum. You can console.log() this to see what value is provided when your filter runs and see if this can be captured in a switch statement or similar. Here's an example in one of my visuals where we ensure that we don't always re-process the view model if there is no need to (e.g. for a resize event).

Another way might be to check and store the value of the options.jsonFilters property at the end of each update as a class property, so that you can compare it value from the last update to its value in the current one and handle your visual workflow accordingly.

Failing that, you may need specific help from the Custom Visuals team - they don't monitor the Developer forum, but regularly address unanswered topics in the Custom Visuals Development Discussion forum on this board. They can also be reached at pbicvsupport@microsoft.com.

I hope this helps, at least a little. Good luck!

Daniel

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

1 REPLY 1
dm-p
Super User
Super User

Hi @KennethWang,

Pretty much any interaction with your visual is going to trigger its update method, so there might be a way of checking what's actually happening and planning for it.

When the update method runs, the options object exposes a type property, which provides a VisualUpdateType enum. You can console.log() this to see what value is provided when your filter runs and see if this can be captured in a switch statement or similar. Here's an example in one of my visuals where we ensure that we don't always re-process the view model if there is no need to (e.g. for a resize event).

Another way might be to check and store the value of the options.jsonFilters property at the end of each update as a class property, so that you can compare it value from the last update to its value in the current one and handle your visual workflow accordingly.

Failing that, you may need specific help from the Custom Visuals team - they don't monitor the Developer forum, but regularly address unanswered topics in the Custom Visuals Development Discussion forum on this board. They can also be reached at pbicvsupport@microsoft.com.

I hope this helps, at least a little. Good luck!

Daniel

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




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.