Share This Post

Main Slider / Power BI

Power BI Embedded using Postman

Power BI Embedded using Postman

This article explains how you can embed the dashboard in your application with Row-level security and securing the reports based on user accessing the report.

Data example: https://docs.microsoft.com/en-us/power-bi/sample-customer-profitability

It has data from customer-related information and assigned a salesperson who does the work

Pre-requisite:

  1. Power BI Pro license and postman to test the APIs
  2. Data should be structured in a way which has a column with Owner that matches the filter you are trying to add.
  3. Postman app

To help you understand the sample code and data to download

  • Customer table has Customer ID
  • Fact table has the customer key which connects to Customer table via Customer ID
  • FACT-BU Key connects to BU table via BUKEY and find BU-Executive-ID to find the executive assigned to the customer
  • Executive-ID would give the field Executive-Name in Executive table

With the above data logic you could get the name of the executive responsible for the specific sales and to be able to work on below requirement:

Goal: Goal is to deploy a similar dashboard and add Row level Security to only show the customer information to the sales person being assigned and for admin show to all users.

Follow below steps after you Launch Power BI

Create a workspace which would store the specific report. https://app.powerbi.com/home

Login to the above link and follow below steps:

  1. Click on workspace
  2. Click on “Create a workspace”
  3. Add workspace name
  4. Add description
  5. Click on Save

Power BI Pro Create Workspace

Now open the PBIx file and click on Publish and it would pop up for you to select the workspace and select the workspace created in the step above.

Power BI Pro Publish pbix file

App Registration

Registered an App on Power BI using https://dev.powerbi.com/apps

  1. Enter the display name of your choice.
  2. Enter the application type
  3. Enter any home page URL of your choice.
  4. Enter a redirect URL
  5. Select checkbox “Select All” for API access.

Register your Application Power BI Pro

Click on Register at the bottom of the page to get the Application ID and application secret.

Application Id, Application Secret after successful registration

Note Application ID & Application Secret.

Successful Registration of Application

Below steps lists down how you can publish and embed the reports on a webpage

And also how you could add the Row level security so user only sees the relevant data for them and not for others.

There are couple of steps involved on how you could do this:

  1. Get the access token
  2. Get the list of all groups i.e. workspaces and find the relevant ID for the group we are using
  3. Generate Embed token
  4. Find the ID for Specific report
  5. Set up Row level security for the report
  6. Create DAX expression to filter for specific users
  7. Generate Token with Row level security
  8. Embed the report using the token and Row level security filter as above.

Step 1 Generate Access Token

Generate access token using the client Id, secret and username/password that was generated in the last step.

Generate Access Token in Postman using Power BI Pro Client ID and Secret

If you get an error as below “ The user or administrator has not consented to use the application with ID… “

This means that either you are not the admin or you have not consented to use the application

So in order to do this you would need to go through the Azure portal as below:

https://portal.azure.com/

  1. Go to Azure active directory
  2. App registration
  3. Go to CRM sales
  4. Go to API permissions

Click on “Grant Access….”

CRM Sales in Azure Active Directory

Active directory admin needs to provide permission for some of the API that we selected above.

Grant Consent through API Permission in Azure Active Directory

Now run the generate access token again and get the Token ID:

Run Access Token in Postman

Step 2 Get all groups

Get all powerBI group details using groups API (Group in PowerBI is same as workspace)

https://api.powerbi.com/v1.0/myorg/groups

Pass the “access token” value from step 1 in “Authorization” header and will give you Group ID which is the workspace ID which you used for publishing the report.

Get Group ID from Postman

Step 3 Get Report details

Get all report details within the group using the group id found in step 2

https://api.powerbi.com/v1.0/myorg/groups/{GroupId}/reports

This would give you the specific report ID that is published in the group.

Get Power BI Pro Report Details in Postman

Step 4 Generate Embed Token

Generate embed token for the report using the report Id from step3 and groupId from step2

Remember to add the same bearer token in header and in body as below to get the embed token

https://api.powerbi.com/v1.0/myorg/groups/{GroupId}/reports/{ReportId}/generatetoken

This token helps you to display the report on a webpage.

Generate embed token using Group ID in Postman

Step 5 Access the report without Row Level Security

Below link can be used to access the report using the EmbedToken

https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html#

It also shows the JavaScript code which can be used to access the dashboard.

  • Embed Token: Pass the Embed Token from Step 4
  • Embed URL: From Step 3
  • Report Id: from Step 3

The above value needs to be populated to see the dashboard.

Access Power BI Pro report using embed token in Postman

This gives you a general view of the dashboard.

Step 6 Setting up Row level security

In order to see the row level security add a new calculated column ‘UserName’ in Executive Table, to remove the spaces from name (as space is not a valid character while generating EmbedToken with RLS)

  1. Right click to add a new column
  2. Add formula below to create a new column with User Name.

Setting Row level security in Power BI Pro

Step 7 Create DAX Expression

Updated the ‘Tenant’ Role to use the new ‘UserName’ column and created a new DAX expression using function Username().

  1. Click on Manage roles
  2. Click on Role as Tenant
  3. Click on Create
  4. Click on the table executive
  5. Click to add DAX expression as below[UserName] = USERNAME()
  6. Save the report and Publish again

Username() function Returns the domain name and username from the credentials given to the system at connection time. Publish the report again.

DAX Expression for embedding Row level security

Step 8 Generate embed token with RLS

Below is the API and the request to generate EmbedToken with Row level Security configured for user ‘TinaLassila’

  • Username is one of the entries in executive table
  • Roles: Tenant is the role we defined in the step 8
  • Dataset ID is the value that you get from Step 3

Use API https://api.powerbi.com/v1.0/myorg/groups/{GroupId}/reports/{ReportId}/generatetoken

Sample URLhttps://api.powerbi.com/v1.0/myorg/groups/c57196fc-74ff-444e-b6a7-eceb24acc961/reports/09c71fed-dcee-4698-9f61-4b5c27176f20/generatetoken

Request Body to embed Row level security

Embedding Row Level Security

Step 9 Access the report with Row level Security

Using the embed token the dashboard shows filtered data:

  • Embed Token: Pass the Embed Token from Step 8
  • Embed Url: From Step 3
  • Report Id: from Step 3

Below report is now filtered for user Tina Lassila.

Access Report with Row level security

Share This Post

9 Comments

  1. How can we modify this source data?

  2. aⅼways i usеd to read smаller content whicһ aⅼso clear
    their motive, and that іs also happening with this
    piece of writing which I am reading at thiѕ place.

  3. I love your blog.. very nice colors & theme.

    • We developed it from scratch, we used s simple theme and did custom changes within it. Using php ang bootstrap.

  4. This post will help the internet viewers for building up new webpage
    or even a weblog from start to end.

  5. This is the perfect website for anybody who wishes to understand this topic.
    Excellent stuff, just great!

  6. fantastic submit, very informative. I’m wondering why the other specialists
    of this sector don’t notice this. You should continue your writing.
    I’m sure, you’ve a great readers’ base already!

  7. No we don’t use a plugin, we developed this within using php and bootstrap manipulation.

  8. The article is really excellent. Every time I read it, I get information again.
    The best article I’ve read in a long time. Thank You.

Leave a Reply

situs togel terpercaya situs togel terpercaya 10 situs togel terpercaya situs togel terpercaya slot deposit dana situs togel situs togel terpercaya slot deposit dana situs togel terpercaya situs slot gacor situs togel terpercaya situs judi bola Daftar 10 Nama Situs Togel Terpercaya Dengan Bandar Togel Resmi Terbaik Di Indonesia situs togel terpercaya slot deposit dana situs togel terpercaya situs togel terpercaya situs togel terpercaya situs togel terpercaya 10 situs togel terpercaya situs togel terpercaya slot deposit pulsa situs judi bola slot deposit pulsa slot deposit dana situs togel terpercaya slot deposit dana situs judi bola situs togel terpercaya situs judi bola slot deposit dana slot deposit pulsa situs togel terpercaya slot deposit pulsa dana slot depo dana bandar togel terpercaya Situs togel terpercaya slot online gacor Bandar Togel Terpercaya slot gacor slot deposit dana polisi togel Polisi togel Bandar Togel Terpercaya Bandar Togel Terpercaya slot deposit dana 10rb Bandar Togel Terpercaya Situs Togel Terpercaya Situs Togel Terpercaya slot gacor bandar togel situs slot depo 10k situs slot depo 10k Slot Online Depo 10k slot demo Bandar Togel Terpercaya Situs Togel Terpercaya Slot Deposit Dana Slot Gacor slot demo slot deposit dana Bandar Togel Terpercaya slot gacor Slot Deposit Pulsa Daftar Slot Gacor Bandar Togel Terpercaya Slot Dana 10k slot deposit pulsa tanpa potongan slot gacor Bandar Togel Terpercaya Bandar Togel Hadiah 4d 10 juta Bandar Togel Terpercaya Situs Togel Terpercaya live draw toto macau live draw cambodia live draw china live draw hk live draw sgp live draw sdy live draw taiwan 10 situs togel terpercaya Bandar Togel Terpercaya slot deposit dana bandar togel slot gacor Slot Online Pulsa Slot Online Gacor Bandar Togel Terpercaya slot depo 10k Slot Deposit Pulsa Daftar Slot Deposit Dana Bandar Togel Hadiah 4d 10 juta Terpercaya Bandar Togel Terpercaya Slot Deposit Pulsa slot deposit pulsa Live Result SDY Live Result SGP Live Result HK Situs Togel Terpercaya bandar togel terpercaya Daftar Slot Dana Bandar Togel Terpercaya 10 Situs Togel Terpercaya Live Draw SGP Tercepat Hari Ini Live Draw SDY Tercepat Hari Ini Live Draw HK Tercepat Hari Ini Situs Togel Terpercaya Slot Terpercaya Bandar Togel Online Terpercaya Indonesia Daftar Togel Terpercaya Bandar Togel Terpercaya Daftar Slot Situs Togel Terpercaya Slot Pulsa Daftar Bandar Togel Terpercaya Slot Dana Via Dana Slot Gacor Slot Demo Pragmatic slot online Slot Via Dana Bandar Togel Terpercaya Bandar Togel Terpercaya slot deposit pulsa Slot Deposit Dana Bandar Togel Terpercaya Bandar Togel Terpercaya Slot Deposit Pulsa Tanpa Potongan Slot Dana RTP Slot Live Slot Deposit Pulsa Slot Deposit Dana Bandar Togel Terpercaya Slot Deposit Dana Bandar Togel Terpercaya Bandar Togel Bonus Cashback Terbesar Bandar Togel Terperaya Slot Deposit Pulsa Live Draw Tercepat Bandar Togel Terpercaya Slot Deposit Pulsa Tanpa Potongan Slot Deposit Dana Bandar Togel Terpercaya Bocoran Slot Gacor Hari Ini Slot Demo Data HK, Hongkong Pools Bandar Togel Terpercaya Slot Online Demo slot gacor Daftar Bandar Togel Terpercaya Slot Deposit Pulsa Situs BO Togel Terpercaya Situs Togel Terpercaya Prediksi HK Live Draw HK Situs Slot Online ESMI SLOT Bandar Togel Terpercaya Situs Togel Terpercaya Slot Deposit Dana slot gacor 5 Bandar Togel Terpercaya Situs Slot Online Deposit Pulsa Agen Togel Terpercaya Bonus besar 2022 Slot Gacor Depo 10rb Terbaik IRAMA SLOT Daftar Bandar Togel 2022 Terbaik Terpercaya Hongkong slot deposit pulsa Prediksi Togel Prediksi Togel Hongkong Prediksi Togel Sydney Prediksi Togel Singapore Angka Keramat Prediksi HK Prediksi SGP Prediksi SDY Prediksi HK SGP SDY Prediksi Togel HK SGP SDY Ratu Prediksi Master prediksi Bandar Togel Terpercaya Tiraijd Data Sdy prediksi HK Daftar Slot Live Draw HK Prediksi HK Prediksi SGP Prediksi SDY Bandar Togel Terpercaya 5 Bandar Togel Terpercaya Daftar Bandar Togel Terpercaya 5 Bandar Togel Terbaik Live Draw Cambodia Live Draw HK Live Draw SGP Live Draw SDY Live Draw HK Live Draw SGP Live Draw SDY Live Draw Taiwan Live Draw Toto Macau Live Draw Toto Macau Data SGP Live Draw Cambodia Data HK Live Draw China Live Draw Taiwan Live Draw SGP Paito SGP Paito HK Paito SDY Data SGP Live Draw HK Live Draw HK 6D Live Draw SGP Live Draw Singapore Live Draw Sydney Live Draw SDY Live Draw Cambodia Live Draw Taiwan Live Draw Toto Macau Paito SGP Bandar Togel Slot Online Togel Online Slot Deposit Pulsa Prediksi HK Prediksi HK Prediksi Togel Live Draw HK Data SDY Situs Togel Bandar Togel Terpercaya Bandar Togel Terpercaya Data HK Live Draw SDY Live Draw Sydney Live Draw Cambodia Live Draw Cambodia Live Draw SGP Live Draw SGP Live Draw Taiwan Live Draw Taiwan Live Draw China Live Draw China Live Draw China Live Draw China Hasil Slot Gacor Data SDY Data SGP Slot Pulsa Bandar Togel Terpercaya Slot Deposit Dana Prediksi HK Slot Deposit Dana Slot Deposit Dana Slot Deposit Pulsa Slot Deposit Dana Slot Gacor Dana Live Draw Cambodia Prediksi Suhu Togel Polisi Togel Live Draw Hk Live Draw Hk Bandar Togel Terpercaya Dan Terbaik