Embedding a dashboard using Java in Power BI

0 votes

So, I've created a dashboard in PowerBi that I can load in a .cs page using the sample project but I like to try and use the JavaScript API. I tried using the project [GitHub Sample Project https://github.com/Microsoft/PowerBI-JavaScript] But I am getting error about the models is there a different function I would be using? I belive that I have all of the js library installed but the dashboard will not loaded in my html page.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.7.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.3/es6-shim.js"></script>
    <script src="scripts/step_interact.js"></script>
    <script src="scripts/step_embed.js"></script>
    <script src="scripts/step_authorize.js"></script>
    <script src="/bower_components/powerbi-client/dist/powerbi.js"></script>
    <script>

    $(document).ready(function () {

        // Get models. models contains enums that can be used.
        var models = window['powerbi-client'].models;

        var embedConfiguration = {
            type: 'dashboard',
            id: 'dashboardID',
            embedUrl: 'https://app.powerbi.com/reportEmbed',
            tokenType: models.TokenType.Aad,
            accessToken: 'TokenString'
        };

        var $dashboardContainer = $('#embedContainer');
        var dashboard = powerbi.embed($dashboardContainer.get(0), embedConfiguration);
    });

    </script>
    </head >
            <body>
                <div id="embedContainer"></div>         
</body >
</html >

Nov 30, 2018 in Power BI by Upasana
• 8,530 points
943 views

1 answer to this question.

0 votes
  1. Make sure to use the correct embedURL, you're using /reportEmbed when you should be using /dashboardEmbed.

eventually, your code should look something like this:

$(document).ready(function () {

        // Get models. models contains enums that can be used.
        var models = powerbi.models; // or window.powerbi.models

        var embedConfiguration = {
            type: 'dashboard',
            id: 'dashboardID',
            embedUrl: 'https://app.powerbi.com/dashboardEmbed',
            tokenType: models.TokenType.Aad,
            accessToken: 'TokenString'
        };

        var $dashboardContainer = $('#embedContainer');
        var dashboard = powerbi.embed($dashboardContainer.get(0), embedConfiguration);
    });
answered Nov 30, 2018 by Shubham
• 13,300 points
Hey will you please tell me how we can add global filter on dashboard?

Thanks in advance.

I don't think Power BI still has the feature to add a filter in dashboard unless you have pinned a page from Power BI Report.

The only filtering available is if you have a report page in the dashboard. 

Filtering across visuals in the dashboard is not possible yet.

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/6674820-global-filter-in-dashboards

Related Questions In Power BI

0 votes
0 answers

Create a sample report in power BI using R script

how to create a sample chart using ...READ MORE

Jun 20 in Power BI by Anitha
39 views
0 votes
1 answer

Create a sample visual in power BI using Python script

Follow the below steps: 1. Run Power BI ...READ MORE

answered Jun 20 in Power BI by Cherukuri
• 31,840 points
560 views
0 votes
1 answer

How to rename a column using DAX in Power BI?

Hi Ramya, I found these two function that ...READ MORE

answered Aug 21 in Power BI by anonymous
• 31,840 points
294 views
0 votes
1 answer

Is there a way to convert JSON data to readable table in power bi

Follow these steps step 1 - Click on ...READ MORE

answered Sep 24, 2018 in Power BI by Hannah
• 16,220 points
2,863 views
0 votes
1 answer

How do you embed dashboard using JavaScript in Power BI?

Dashboards in Power BI can be embedded ...READ MORE

answered Mar 5 in Power BI by Phalguni
• 1,010 points
108 views
0 votes
1 answer

Embed URL-multiple filters in Power BI

With the release of 2.0.0 you can ...READ MORE

answered Oct 16, 2018 in Power BI by Annie97
• 2,190 points
1,028 views
0 votes
1 answer

Passing a parameter to Power BI Embedded via embedded URL

Add the following to the end of ...READ MORE

answered Oct 23, 2018 in Power BI by Annie97
• 2,190 points
1,270 views
0 votes
1 answer

Using R packages in Power BI

When you're trying to use R on ...READ MORE

answered Dec 17, 2018 in Power BI by Shubham
• 13,300 points
56 views
0 votes
2 answers

Using R packages in Power BI

You can use the powerful R programming language to ...READ MORE

answered Feb 8 in Power BI by rajesh
• 1,210 points
38 views