Forum Discussion
Custom Visual - Selecting, Filtering and Highlighting
- 8 years ago
Partial solution to the selection problems (issues 1 and 2), but not the fact that other visuals are filtered not highlighted (3).
The problem stems from the fact that when more than one category column is add to createSelectionIdBuilder() it causes the cross-filtering to error when more than one data point is selected.
The fix is to only add one category column to the createSelectionIdBuilder - it doesn't matter which one, and the values in the column appear to be irrelevant. This is counter intuitive if comparing with an SQL select, or any other filtering function which would look to match against the values in the category columns. The resultant code (showing the removed line commented out) is as follows:
const selectionId: ISelectionId = this.host.createSelectionIdBuilder() .withCategory(ageRange, i) // .withCategory(gender, i) .createSelectionId();It would be helpful if PowerBI provided a more useful error message, or error checking, to advise that more than one category is not permitted when cross filtering; or even, have a solution which doesn't throw an error when more than one category is selected.
v-viigThanks for the suggestion, but that doesn't work. All that happens is cross filtering / highlighting no longer works (i.e. clicking on a selection in the visual highlights the selected element, but there is no impact on the other visuals on the page.
You are probably correct that applySelectionFilter is filtering the other visuals, but just using slectionHandler.handleSelection() is insufficient on its own to communicate change to the other visuals on the page.
Can you share the capabilities.json?
I suppose there's a filter property at general group.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- v-viig8 years agoCommunity Champion
The filter propertry must be used if you want to handle selection as filtering.
Csutom filter can be applied if and only if filter property is declared in the capabilities and applySelectionFilter or applyJSONFilter are called.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- diaAzul8 years agoAdvocate IV
v-viig: Yes there is a filter property in capabilities.json.
Link to file on github: Capabilities.json
"objects": { "general": { "displayName": "General", "displayNameKey": "formattingGeneral", "properties": { "selection": { "displayName": "Selection", "type": { "text": true } }, "filter": { "type": { "filter": true } }, "selfFilter": { "type": { "filter": { "selfFilter": true } } } }Is this not correct?
- v-viig8 years agoCommunity Champion
You should remove the filter property and selectionHandler.applySelectionFilter() if you want handle selection as a highlighting.
Please let me know if that works well.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- Anonymous8 years agoNot applicable
v-viig so basically whats the aim of using fitler in capabilities.json ? I don't get it.
- Anonymous7 years agoNot applicable
Hi, Thank for the info, can you explain what the selfFilter is doing? v-viig