我正在尝试在创建模式中对Power Bi报表设置过滤器。我找到了在报表级别,页面级别和可视级别上对数据集设置过滤器的示例,但是当嵌入设置用于报表创建(创建模式)时,过滤器不起作用。
Please find the below code which is for power bi report creation.
var embedDiv = document.getElementById('embedDiv');
const iFilters: IBasicFilter = {
$schema: 'http://powerbi.com/product/schema#basic',
filterType: FilterType.Basic,
target: {
column: 'COLUMN1',
table: 'TABLE1'
},
operator: 'In',
values: ['VALUE1', 'VALUE2'],
};
const configuration = {
'accessToken': 'ae...ex',
'embedUrl': 'https://app.powerbi.com//reportEmbed?groupId=group_id',
'datasetId': 'aex....mky'
};
// The below line gives Create Object.
const embedObject = this.powerBIService.createReport(embedDiv, configuration );
embedObject.on('loaded', function(e){
// the below line gives error because setFilter is a method of Report instead of Create class.
embedObject.setFilter([iFilter]);
});
在加载用于创建图表的数据集时,还有其他方法可以过滤数据吗?
答案 0 :(得分:0)
您可以直接在嵌入式配置中定义过滤器,而不必通过调用embedObject.setFilter([iFilter]);
来设置过滤器运行时:
const configuration = {
filters: [iFilter], <-- add this line
'accessToken': 'ae...ex',
'embedUrl': 'https://app.powerbi.com//reportEmbed?groupId=group_id',
'datasetId': 'aex....mky'
};