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,620 points
5,213 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);
    });

If you are interested in learning more about Power BI, then check out the affordable Power BI certification cost now!

answered Nov 30, 2018 by Shubham
• 13,490 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, 2019 in Power BI by Anitha
723 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, 2019 in Power BI by Cherukuri
• 33,030 points
7,727 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 22, 2019 in Power BI by anonymous
• 33,030 points

edited Dec 31, 2021 by Soumya 38,429 views
0 votes
1 answer

How to create a new dashboard by pinning visualizations from a report in Power BI?

Hey, I can show some steps wise steps ...READ MORE

answered Feb 6, 2020 in Power BI by Gitika
• 65,770 points
1,165 views
0 votes
1 answer

How do you embed dashboard using JavaScript in Power BI?

Make sure the use the correct embedURL ...READ MORE

answered Oct 10, 2023 in Power BI by Monika kale

edited Mar 5 2,154 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,160 points
4,002 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,160 points
5,061 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,490 points
852 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, 2019 in Power BI by rajesh
• 1,270 points
1,098 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP