Forum Discussion
Support other visuals' selection in custom slicer
- 7 years ago
Hi,
To merge filtration, you should use applyJsonFilter with "merge" option.
Kind Regards,
Evgenii Elkin,
Software Engineer
Microsoft Power BI Custom Visuals
[email protected]
Hi,
To merge filtration, you should use applyJsonFilter with "merge" option.
Kind Regards,
Evgenii Elkin,
Software Engineer
Microsoft Power BI Custom Visuals
[email protected]
- Anonymous7 years agoNot applicable
Thank you, v-evelk
Before I had received your answer I decided to build custom chart visual and filter dates programmaticaly there. After I had completed I returned to topic problem.
I describe steps to achieve the goal. It may be useful to someone.
1) Install powerbi-models using following command in project folder.
npm install --save powerbi-models
2) Add link to pbiviz.json.
"externalJS": [ "node_modules/powerbi-models/dist/models.js" ]3) Add link to tsconfig.json.
"files": [ "node_modules/powerbi-models/dist/models-noexports.d.ts" ]4) Add following code to update method. (The date to be selected should be under first (zero index) category.)
const conditions: IAdvancedFilterCondition[] = [ { operator: "GreaterThanOrEqual", value: new Date(startMillis) // First date. }, { operator: "LessThanOrEqual", value: new Date(endMillis) // Last date. } ]; const categories: DataViewCategoricalColumn = options.dataViews[0].categorical.categories[0]; const target: IFilterColumnTarget = { table: categories.source.queryName.substr( 0, categories.source.queryName.indexOf('.')), column: categories.source.displayName }; const filter: IAdvancedFilter = new window['powerbi-models'] .AdvancedFilter(target, "And", conditions); this.visualHost.applyJsonFilter( filter, "general", "filter", FilterAction.merge ); - Anonymous7 years agoNot applicable
v-evelk, additional question. How can one support others' selection in custom matrix visual? I see
IFilterKeyHierarchyTarget but how to fill it and how to set conditions for all levels of hierarchy? This topic tells that only one filter can be applied.- v-evelk7 years agoMicrosoft Employee
I am not sure about matrix. If it uses selectionManger, you can try to use selectionManager with the second parameter as 'true' to enable multi-selection.
this.selectionManager.select(selector, true).then((ids: ISelectionId[]) => { //called when setting the selection has been completed successfully });Regarding IFilterKeyHierarchyTarget I will ask our engineers and provide info here later.
Kind Regards,
Evgenii Elkin,
Software Engineer
Microsoft Power BI Custom Visuals
[email protected]- Anonymous7 years agoNot applicable
Yes, I use ISelectionManager to filter data from custom matrix visual.
Unfortunately, true in select doesn't change the behavior. My custom visuals (matrix and slicer) go to infinite selection loop. Standard line chart shows data selected by matrix for a second. Then it shows data selected by slicer for another second. After that it shows data selected by matrix again. And this process continues until I close Power BI.
With standard matrix visual all the elements work fine.