在Power BI报表中设置活动页面

时间:2020-08-06 10:05:02

标签: powerbi

我的报告有4页。我需要根据客户当前正在浏览的网站显示不同的页面。最初,我有4种不同的配置,可将报告加载4次。当然,这会对性能产生巨大影响,根本不是正确的解决方案。

起初,我已经尝试过了

var report = powerbi.embed($reportContainer.get(0), embedConfigurationMain);
report.setFilters([basicFilterMain, stocktakeIdFilterMain]);
var page = report.page('ReportSectionxxxxxxxxx');
page.setActive();

但它仍显示报告的默认页面。

然后我在https://community.powerbi.com/t5/Developer/set-active-page-in-report-with-JavaScript-API/m-p/93716#M..找到了一个类似问题的人。并尝试了建议的解决方案,但出现以下错误:

Uncaught TypeError: Cannot read property 'setActive' of undefined

然后我继续检查Power BI Playground,并使用他们在此处提供的确切代码,

report.getPages()
.then(function (pages) {
    pages[0].setActive()
        .then(function () {
            Log.logText("Active page was set to: \"" + pages[0].displayName + "\"");
        })
        .catch(function (errors) {
            Log.log(errors);
        });
})
.catch(function (errors) {
    Log.log(errors);
});

但是仍然没有喜悦,什么也没有发生。甚至没有在控制台中收到消息。

在JavaScript API中设置活动报告页面的正确方法是什么?我正在使用Power BI Embedded SDK的最新版本。

2 个答案:

答案 0 :(得分:1)

有一个针对您目的的解决方法。如您所说,您拥有不同的网站,并且您希望根据请求来自哪个网站来在报告中显示不同的页面。

您可以通过Power BI服务在报告中列出其他页面的浏览器URL。只需转到报告的其他页面,您将获得页面明智的链接。您可以看到,同一页面将始终在浏览器中生成唯一的URL。因此,如果您的报告中有4个页面,您将从浏览器中获得4个唯一的URL。

现在,您可以在网站的链接中设置目标URL(特定于页面)。希望这个技巧能起作用。

答案 1 :(得分:0)

您看到的“未定义”错误的原因是import java.util.*; public class MyClass { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Please enter text (type DONE to quit): "); String text = ""; String output = ""; while (!"DONE".equals(text)) { text = input.next(); output += text.replace("DONE", "") + " "; } String[] numOfWords = output.split(" "); int numOfChars = output.replace(" ", "").length(); System.out.print("Number of words: " + numOfWords.length); System.out.println(""); System.out.print("Number of non-space characters: " + numOfChars); } }

更改为:

pages[0].setActive()
相关问题