image.png

🗒️Table of Contents

Overview

In a previous post, I introduced the Power Apps visual in Power BI and demonstrated how embedded canvas apps can be used to create new records and edit existing data. But canvas apps offer much more — especially when you leverage their built-in connectors such as the Outlook connector. This post explores one such scenario: enabling managers to schedule meetings between Help Desk technicians and requestors directly from a dashboard displaying overdue tickets — all without leaving Power BI.

Setting Up the Power BI Report

This approach works with any data source, and the query mode (import or DirectQuery) does not matter. Therefore, set up your Power BI report as you normally would. My simple report presents data from a single table of Help Desk tickets. It contains a page with a table listing all overdue open tickets. Although in the screenshot below you can see the embedded canvas app, you should create your report with all other visualizations in Power BI Desktop, then publish this file without the embedded app to Power BI Service. We will be adding and configuring the app from Power BI Service.

image.png

Setting Up the Canvas App

  1. From your published report in Power BI Service, click Edit.
  2. Insert the Power Apps for Power BI visual and resize/reposition as needed.
  3. Add any fields you want to include in your app into the PowerApps Data well. From the dataset, I will be including the Assignee Email, Requestor Email, and Request ID in my Outlook invite.

image.png

  1. In the Power Apps visual, click Create new. This will open Power Apps studio in your browser.

  2. Set up the basic design of your app:

    1. Insert a header to give your app a title
    2. Insert a text box to indicate who the user is scheduling an appointment with once they have selected a record:
    "Scheduling meeting with " & 
    First([@PowerBIIntegration].Data).RequestorEmail & // the requestor's email address passed from Power BI
    " (requestor) and " & 
    First([@PowerBIIntegration].Data).'Assigned To Email' & // the assigned technician's email passed from Power BI
    " (technician) regarding " & 
    First([@PowerBIIntegration].Data).'Request ID' // the request ID passed from Power BI
    

    NOTE: To refer to the selected record being passed from Power BI, you use the First( ) function because the data is passed from Power BI in a table format and this returns the first (and only) record. [@PowerBIIntegration].Data gets you the object being returned from Power BI, and adding a period after that will display all the fields you can access. If a field isn’t appearing for you here, make sure it is added to the Power Apps visualization data well (see step 3).

  3. Add 4 text labels for Appointment Date, Start Time, End Time, and Message.

  4. Add a Date Picker control for the appointment date.

  5. Configure your start and end time controls as a dropdown. Set the Items property of these controls to the time range you want to allow appointments to be scheduled. Mine are set to every 30 minutes between 9:00 AM and 4:30 PM for start time and between 9:30 AM and 5:00 PM for end time. Sample Items property code for start time:

[    "8:00 AM", "8:30 AM", "9:00 AM", "9:30 AM", "10:00 AM", "10:30 AM",    "11:00 AM", "11:30 AM", "12:00 PM", "12:30 PM", "1:00 PM", "1:30 PM",    "2:00 PM", "2:30 PM", "3:00 PM", "3:30 PM", "4:00 PM", "4:30 PM"]

  1. Add a text input control for the Message.

  2. Add a button to schedule the meeting.

    1. On the left pane, select the Data icon and add the Office365Outook connector.

      image.png

    2. Update the button’s Onselect property to do 3 main things: create the calendar invite, display a success message on the app screen, and reset the controls to blank.

    // create the Outlook invite
    Office365Outlook.V4CalendarPostItem(
      "Calendar", // the name of the calendar to post to
      "Meeting Regarding " & First([@PowerBIIntegration].Data).'Request ID', // set the subject 
      Text( // creates the start date and time formatted for Outlook
        DateTimeValue(
          Text(DatePickerCanvas1.SelectedDate, "[$-en-US]yyyy-MM-dd") & 
          " " & drp_starttime.Selected.Value
        ),
        "[$-en-US]yyyy-MM-ddTHH:mm:ss"
      ),
      Text( // creates the end date and time formatted for Outlook
        DateTimeValue(
          Text(DatePickerCanvas1.SelectedDate, "[$-en-US]yyyy-MM-dd") & 
          " " & drp_endtime.Selected.Value
        ),
        "[$-en-US]yyyy-MM-ddTHH:mm:ss"
      ),
      "Eastern Standard Time", // sets the time zone
      {
        requiredAttendees: // invitees
          First([@PowerBIIntegration].Data).RequestorEmail & ";" & 
          First([@PowerBIIntegration].Data).'Assigned To Email',
        body: inp_message.Value // body of the message
      }
    );
    
    // display success banner in the app
    Notify(
      "Your meeting has been scheduled",
      NotificationType.Success,
      5000
    );
    
    // reset all controls to blank
    Reset(DatePickerCanvas1);
    Reset(drp_starttime);
    Reset(drp_endtime);
    Reset(inp_message);
    
    
    1. For a better user experience, I like to add a text control that overlays the screen but is only visible if a user hasn’t selected a record in Power BI. This app works on one record at a time, so when the user first opens the screen I don’t want them to be able to access the scheduling functionality. Insert a text control, give it a solid color background, and make sure it is at the top of your tree view so it blocks other controls when it is visible. Set its visibility to:
    CountRows(PowerBIIntegration.Data) <> 1
    

    We use this construction rather than something like IsBlank( ) or IsEmpty( ) because when the canvas app first loads up in Power BI, it interprets all records as being selected (rather than none). So if I had 100 total records in my table and I ran the above Countrows( ) function, when my dashboard first loaded up the app would show 100 rows being counted. Therefore, we want to show the text box when no selection has been made; that is, when Countrows( ) is returning anything other than 1.

Access, Permissions, and Other Notes