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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
aarshps
Frequent Visitor

Access filters in Custom Visual

Hi,

 

I have a custom visual in which I need to access the page filters that are being applied. How can I get the filters from my Custom Visual code?

 

I am trying to create a custom visual somewhat similar to MAQ software's JSONGrid Viz. I also need to add an additional functionality of have a filter element to control the number of columns in the Viz. That is there will be a multiselect to select the columns for the table.

 

I'm fairly new to Power BI.

7 REPLIES 7
v-chuncz-msft
Community Support
Community Support

@aarshps,

 

You may take a look at Using the advanced filter API and view source code of JSON Grid at https://github.com/maqsoftware/PowerBI-visuals/tree/master/src/CustomVisuals/Published/JSONGrid.

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

I have been looking into the source code.

 

My doubt is how can I have a multi-select like thing in my application and let the user select a list. Then the visualization that is created should have only the columns in the list selected by the user.

v-viig
Community Champion
Community Champion

Power BI Custom Visuals API doesn't support the ability to get filters that are applied on the page.

 

Could you please explain the second feature a bit deeper?

 

I also need to add an additional functionality of have a filter element to control the number of columns in the Viz. That is there will be a multiselect to select the columns for the table.

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

 

Please click to see the image

 

I've attached a link to what I would like to achieve. Based on that multi-select present just beside the visual, the columns need to change dynamically. So what I need to have is the selections from the slicer to the custom visual.

 

I need to get the values selected for the slicer inside the custom visual's update(). Will I be able to do it?

 

v-viig
Community Champion
Community Champion

I think that's impossible to achieve since columns must be specified at Fields panel.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Thank you for letting me know. But still, I could achieve the same using a matrix visualization. My doubt is, will I be able to achieve it with custom visuals? Somehow? Even the solution might not look clean, can it be done?

jppp
Continued Contributor
Continued Contributor

The behavior you describe is default behavior of Power BI: the dataset available in your (custom) visual is already filtered by other filters from the Power BI. So if you filter on one column, only that column is available in your visual. And if you change that slicer that columns (name and values) are available.

 

Just try and create a 'simple' empty custom visual only with the dataRoles and dataViewMapping defined and look at the data view of the developer visual to see what dataset is available.

 

-JP

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.