User relevant Power BI components in Power Pages

Do you want to have a different Power BI component configuration in Power Pages depending on who is logged in, making the data user relevant?

User relevant Power BI components in Power Pages Microsoft Office 365 image 15

Some background

How about creating a page in Power Pages that lets you display Power BI reports depending on the user that is logged in? So depending on which company a user works at, they get a different report shown?

So for different companies I have a different Power BI report to be displayed.

In this post I will give an example of how to implement this. You will need to get a little familiar with Liquid first. So please have a look at my post introducing Liquid first.

If you are completely new to Power Pages then have a read through my ultimate user guide on Power Pages

Get the company

In my case I don’t really want to company name of my logged in user. I rellay want the get the domain of the user. So the but after the @ sign in their email address.

To get the part after the @ sign we can use the filters split and last as shown below:

{% assign mycompany =  user.emailaddress1 |split:"@" |last  %}

{% if mycompany %}
         <div style="padding: 8px; margin: 0px; display: flex; flex-wrap: wrap; text-align: left; min-height: 50px;"> Your Company: {{ mycompany }} </div>
{% endif %}

Then the last few lines will display the domain name of the user logged in.

Get the data

Now we need to get the data from a table that we created that holds the links to Power BI

We will use a fetchXMl for this:

{% fetchxml mylinks %}

<fetch version=”1.0″ output-format=”xml-platform” mapping=”logical” distinct=”true”>

   &lt;entity name=&#8221;creb7_clientpowerbilinks&#8221;&gt;



     &lt;attribute name=&#8221;creb7_powerbilink&#8221; /&gt;



     &lt;attribute name=&#8221;creb7_name&#8221; /&gt;



   &lt;/entity&gt;



 &lt;/fetch&gt;

{% endfetchxml %}

In the above coded there are a few things to notices. The data that is read with the fetchxml is stored within a variable mylinks. Then the table that is being read has a logical name, creb7_clientpowerbilinks and there are two fields creb7_powerbilink and creb7_name.

Processing the data

So no we have an array called mylinks with all the data that we want. using a for loop we can display a Power VBI report with the link in question.


    {%for item in mylinks.results.entities %}
       {% if item.creb7_name == mycompany %}
         {% powerbi authentication_type:"aad" path:item.creb7_powerbilink %}
       {% endif %}
    {% endfor %}

Display the Power BI component

For ease here is the full code as built up in this post.

{% assign mycompany =  user.emailaddress1 |split:"@" |last  %}
    {% if mycompany %}
    <div style="padding: 8px; margin: 0px; display: flex; flex-wrap: wrap; text-align: left; min-height: 50px;"> Your Company: {{ mycompany }} </div>
    {% endif %}

    {% fetchxml mylinks %}
    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
      <entity name="creb7_clientpowerbilinks">
        <attribute name="creb7_powerbilink" />
        <attribute name="creb7_name" />
      </entity>
    </fetch>
    {% endfetchxml %}
    
    {%for item in mylinks.results.entities %}
      {% if item.creb7_name == mycompany %}
        {% powerbi authentication_type:"aad" path:mylink.creb7_powerbilink %}
      {% endif %}
    {% endfor %}

The above code should then give you the Power BI report in your Power Pages that is built up dynamically.

user relevant Power BI component

Continue Reading Pieter Veenstra’s Article on their blog

User relevant Power BI components in Power Pages

Do you want to have a different Power BI component configuration in Power Pages depending on who is logged in, making the data user relevant? How about creating a page in Power Pages that lets you display Power BI reports depending on the user that is logged in?

Blog Syndicated with Pieter Veenstra’s Permission

Author: Pieter Veenstra

Share This Post On
Share via
Copy link
Powered by Social Snap