我试图在创建模式下设置功率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]);
});
在我们加载数据集以创建图表时,是否有其他方法可以过滤数据?
您可以通过调用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'
};