【问题标题】:Power BI dataset filter in Create Report mode创建报表模式下的 Power BI 数据集筛选器
【发布时间】:2019-02-15 20:36:20
【问题描述】:

我正在尝试在 创建模式 中对 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]);
});

当我们加载数据集以创建图表时,还有其他方法可以过滤数据吗?

【问题讨论】:

    标签: powerbi powerbi-embedded powerbi-datasource


    【解决方案1】:

    您可以直接在嵌入式配置中定义过滤器,而不是通过调用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'
    };
    

    【讨论】:

    • Andrey,我尝试了上面的代码,但它不适用于创建模式。它仅适用于现有报告。
    猜你喜欢
    • 2022-01-18
    • 1970-01-01
    • 2021-03-21
    • 2021-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多