Forum Discussion

SeymaKalay's avatar
SeymaKalay
Frequent Visitor
1 year ago
Solved

send powerbi table via email to team managers using Power Automate

I have created a powerbi table as below. Using Power Automate, I would like to send an email to team managers so they can see only their team members only. Something more complex than this. Many than...
  • AmiraBedh's avatar
    1 year ago

    Hello !

    Thank you for posting on Fabric community.

     

    Your dataset must have at least these columns: User, Info, Manager, ManagerEmail and the report workspace must be on PPU or on Premium capacity.

    For the trigger set up the recurrence and in PBI, for run a query against a dataset go to the managers list :

    EVALUATE
    SUMMARIZECOLUMNS(
    'Employees'[ManagerEmail],
    'Employees'[Manager]
    )

    Then run a query against a dataset for all rows :

    EVALUATE
    SELECTCOLUMNS(
    'Employees',
    "User", 'Employees'[User],
    "Info", 'Employees'[Info],
    "Manager", 'Employees'[Manager],
    "ManagerEmail", 'Employees'[ManagerEmail]
    )

     Then set these variables :

    AllRows (Array) = body('All_rows')?['results'][0]['tables'][0]['rows']
    Managers (Array) = body('Managers_list')?['results'][0]['tables'][0]['rows']

     

    and apply to each  Managers

    • Set variable mgrEmail = items('Apply_to_each')?['ManagerEmail']

    • Set variable mgrName = items('Apply_to_each')?['Manager']

    • Filter array from AllRows, condition:

    @equals(item()?['ManagerEmail'], variables('mgrEmail'))
    

     

    If filtered array length > 0:

    • Create HTML table from the filtered array

    • Compose (HTML wrapper):

    <style>
      table{border-collapse:collapse;font-family:'Segoe UI',Arial;font-size:12px}
      th,td{border:1px solid #ddd;padding:6px} th{background:#f3f2f1;text-align:left}
    </style>
    <p>Hello @{{variables('mgrName')}},</p>
    <p>Here’s your current team list:</p>
    @{outputs('Create_HTML_table')}
    <p>– Automated message</p>
    

     

    and in the Send an email (V2), fill the To, Subject, Body and Turn Is HTML to yes.