Categories: Microsoft Office 365

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?

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”>

<entity name=”creb7_clientpowerbilinks”>

<attribute name=”creb7_powerbilink” />

<attribute name=”creb7_name” />

</entity>

</fetch>

{% 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.

Share
Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

Recent Posts

1 step to update an item in an array in Power Automate

What do you do when you have an array of data in Power Automate and…

6 days ago

Failed to load in Azure Synapse Workspace

After last week's post about how to configure Azure Synapse Link to export data from…

1 week ago

Buckinghamshire & Northamptonshire Power Platform User Group launch

Have you been waiting for a new face to face Power Platform User Group in…

1 week ago

Configure Dataverse exports using Azure Synapse Links for Azure SQL Databases

In this post I'm looking at the Azure SQL databases option that is part of…

2 weeks ago

5 steps to implement word based search in Power Apps

A common requirement in Power Apps is to create a word based search on data…

3 weeks ago

900th post on SharePains.com, it is a time to celebrate and win!

This is the 900th post on SharePains.com and I thought this would be a good…

1 month ago
%%footer%%