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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

pbicvsupport@microsoft.com

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

pbicvsupport@microsoft.com

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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