Logic Apps, Flow, PowerApps – Extracting List Data to Excel, One Record at a Time.

Today I was faced with an enjoyable challenge.  I was asked to determine if it was possible to create an entry form within Office 365 that could collect data and then email the data collected within the entry form to someone as an attachment.  The attachment had to be in a Excel compatible file format with column headers.

I started off by creating a simple list in SharePoint Office 365. In this test case, my list is titled; Job Requisition.  Here I have a few columns of different data types titled “Job Title” (Single Line of Text), “Job Description” (Multi-line Text Box), “Department” (Choice) “Hire By Date”(Date), “Salary” (Number)

powerapp1

I created a mobile PowerApp form to modernize the user input experience, however a regular list input forms work just as well.  Once a user fills out the input form, data is saved to the list.

powerapp2.PNG

In this example, I decided to use Flow as my programming platform, though in production, Logic Apps may be the preferred solution of choice.

The Flow has 4 steps:

  • Initiation
  • Composition
  • CSV Creation
  • Send Email

powerapp3.PNG

Step 1 – launches the Flow based around a new item being created

 

Step 2 – is a data operation step where we extract the data from the current item list entry into an  array.  I must admit this step was a bit tricky as the syntax isn’t well documented.  

I decided to use the Data Operation – Compose action and then utilize the expression builder to extract the array from the trigger output of the current item that the Flow is running against.

Here we can see how the expression builder is being used to create the array for the object.

powerapp4.PNG

Here is the syntax for the expression.

createArray(triggerOutputs()?[‘Title’]?[‘Job Description’]?[‘Department Value’]?[‘Hire By Data’]?[‘Salary’])
You’ll notice the syntax is a little goofy.

 

Step 3 – Next we use this object created from the array to create a CSV table using another data operation action.

You are also able to create column headers and determine the “values” under the header from the object created by the array.

This allows us to select the display value and not the stored value for drop downs.  We can also use this to help strip out html and markup from our data results

powerapp5.PNG

Step 4 – We use the Send an Email action to build our email. The trickiest part here is specifying the file format we are using and defaulting this to an Excel friendly format.  Since we are using the Create CSV Table action in Step 3, we are able to give our file a generic name with the “.csv” extension for Microsoft Excel to automatically open the file.

powerapp6

Here is the email that is sent.

powerapp7

Here is the CSV / Excel file that is generated.

powerapp8.PNG

Pretty cool and useful. This is also functionality that was not available in InfoPath unless code behind was used.

Advertisements

On Premise Databases with Office 365 and Power BI

This post is meant to be a semi-technical primer into connection On-Premise data to Office 365 and Power BI…

Behold, the On-Premise Data Gateway.  The On-Premise Data Gateway is a free tool developed by Microsoft that allows the connection of multiple on-premise data sources to connect to an Office 365 environment.  This tool allows developers to build applications within Office 365 that reference on-premise data sources.

A word of caution, in this example, the On-Premise Data Gateway will be running on my local machine, in production, the On-Premise Data Gateway should be executed from a machine that is always on and connected to the internet, perhaps a Window Server.

The On-Premise Data Gateway can be downloaded from the following link.  http://go.microsoft.com/fwlink/?LinkID=820925

Installation

The installation process is essentially a series of “Next”

Step 11

Step 22

Step 33

Step 44

Step 5 – In Step 5 we start the process of entering our Office 365 login credentials.5

Step 66

Step 7 – Here we name our gateway and create a “Recovery Key”7.PNG

Step 8 – Magic!  Our gateway is created and connected to Office 365 and Power BI8.PNG

In this case, I am using the “AdventureWorks Internet Sales” tabular data model, though other data sources exist.  I am leverage SQL Server 2017 Developer Edition running locally on my laptop where my On-Premise Data Gateway is also running.

10.PNG

First, you must log into your Office 365 instance and have the appropriate access to Power BI.  You can use the same credentials that you are using to create your On-Premise Data Gateway to access Office 365 and Power BI and to create your Power BI dashboard, though this is not required.

We will then need to select the gear at the top of the Office 365 / Power BI and select “Manage Gateways

21.PNG

Here we will select “Add data source to use the gateway”  On this screen we enter the data source of our Analysis Services Tabular model and provide on-premise credentials that can access Analysis Services.

22.PNG

Now we will go back to our workspace home page of Power BI and select the “Get” button under “Databases” under “Import or Connect to Data”

9.PNG

Then select “SQL Server Analysis Services11.PNG

Then select “Connect12.PNG

Now we will see a warning and it appears we are unable to connect.13.PNG

However, we need to select the drop down arrow at the top of the screen launch the download of “Power BI Desktop”14.PNG

Power BI Desktop installs by selecting “Next” multiple times and accepting the license agreement.

Once installed, you will receive a prompt to create a Power BI account or to sign in with an existing account.

15.PNG

Once inside of Power BI Desktop, we can then select “Get Data” and choose “Analysis Services16.PNG

On the next screen we enter our Analysis Services Tabular instance and select connect live.  17.PNG

We then navigate to our Tabular Data Model.18.PNG

Now we can build a simple dashboard.  I am going to select “Clusterd column chart” with “Sales Amount” as my Axis and “Order Quantity” as my Value.19.PNG

Then we can select Publish, save our dashboard, and publish the dashboard our workspace within Power BI.20.PNG

Once this is completed, we will now see a successful message.23.PNG

Note, that the success screen states that the …report has been configured to use an enterprise gateway.  Enterprise Gateway was the old name for “On-Premise Data Gateway