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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
danieleperilli
Kudo Commander
Kudo Commander

Multi fields slicer and bookmarks

My visual works like a slicer, you can add several categories and each of them is rendered as a HTML list.


With a single category, all is pretty simple because each item of the list is represented by just one selectionId.
With two o more lists, the things become more complex because every item is represented by multiple selectionIds that contain the lowest grain of all categories added.


So, with multiple lists, when the user selects an item, my visual has to pass several selectionIDs to the selectionManager in order to filter the report properly.
It is not a big issue, but my problems start when the user clicks on a bookmark.
In this case, my visual receives a complex filter. Analyzing the filter, I'm not able to know which list was real selected, so I have to select all the values passed.

 

Take a look a these screenshots: the first one shows what the user has selected (just the category Computers), the second one is a fragment of the filter received after a bookmark with the same selection (just the category Computers) is clicked, the third one is the bookmark render.

 

wanted.png

filter.png

not-wanted.jpg

In this example, I don't want to select all the subcategories, just the parent category, but I have to do so, beacuse they are stored in the filter.

 

I tried to solve the issue by using different approaches.
I tried to apply the selection with a BasicFilter instead of selectionManager with multiple selectionsIds, but I'm not able to add different columns to the same BasicFilter or to apply different BasicFilters with host.applyJsonFilter() function.
So I tried an undocumented (and unsupported, I guess) way, inspired by your FilterManager.restoreSelectionIds() function.
Something like this:

 

let category = ...; //DataViewCategoryColumn
let value = ...; //Text value
let fieldExpr = powerbi["data"].SQExprBuilder.fieldExpr({ 
      column: { 
          entity: category.queryName.substr(0, category.queryName.indexOf('.')), 
          name: category.source.displayName 
      } 
});
let expr = powerbi["data"].SQExprBuilder.equal(fieldExpr, powerbi["data"].SQExprBuilder.text(value));
let identity = powerbi["data"].createDataViewScopeIdentity(expr);
let selectionId = (<any>powerbi["visuals"]).SelectionId.createWithId(identity);
this.selectionManager.select(selectionId, true);

The code above works only with selections from the same category, but produces an advanced filter and breaks the report when multiple categories are involved.

 

Can you help me in understanding how to solve my issue?

 

Thanks.

1 ACCEPTED SOLUTION
v-viig
Community Champion
Community Champion

Power BI CV API does not support multi column filtering well.

We're developing an API to support multi columns filtering but there's no ETA.

 

We'll share more details later once design and implementation is done.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

[email protected]

View solution in original post

1 REPLY 1
v-viig
Community Champion
Community Champion

Power BI CV API does not support multi column filtering well.

We're developing an API to support multi columns filtering but there's no ETA.

 

We'll share more details later once design and implementation is done.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

[email protected]

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.