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]
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
);