Power BI – BMC Software | Blogs https://s7280.pcdn.co Wed, 10 Mar 2021 14:29:15 +0000 en-US hourly 1 https://s7280.pcdn.co/wp-content/uploads/2016/04/bmc_favicon-300x300-36x36.png Power BI – BMC Software | Blogs https://s7280.pcdn.co 32 32 Power BI Visualization Types https://s7280.pcdn.co/power-bi-visualization-types/ Wed, 10 Mar 2021 14:29:15 +0000 https://www.bmc.com/blogs/?p=20389 This articles sums up some of the most common visualizations in Microsoft Power BI Desktop. (Remember that you create reports in BI Desktop and then publish them to powerbi.com.) (This article is part of our Power BI Guide. Use the right-hand menu to navigate.) Power BI standard visualizations Power BI has the normal set of […]]]>

This articles sums up some of the most common visualizations in Microsoft Power BI Desktop. (Remember that you create reports in BI Desktop and then publish them to powerbi.com.)

(This article is part of our Power BI Guide. Use the right-hand menu to navigate.)

Power BI standard visualizations

Power BI has the normal set of visuals in the default product. The palette of standard visualizations looks like this:

But the product is made better by third-party visualizations, where anyone can contribute a new or variant visualization to a central repository.

Power BI visuals

Here are some of the other Power BI Visuals:

Pie chart

The icons from the visualization palette are too small to copy here. Fortunately, the pie chart looks like a pie. Hover the mouse over the palette and the name fill pops up.

Like the histogram, the pie chart divides the data set into slices that together sum to 100%.

This example is expenses by category. The percentage and amount would make the chart too crowded if they were all added there. So that is done using tooltips, which are popups to show additional information.

Funnel

Here is the funnel. It also sums to 100%. This shows spending by category in descending order.

Stacked bar chart

A bar chart gives two dimensions, meaning one metric on the x axis and one on the y axis. To add another metric, you can use the actual bar itself to convey information.

In this stacked bar chart, we not only have spending by category, we have it by account. The vertical lines are scaled so that the first column represents one amount, while the second shows a different amount. That lets each line be the same height.

In the funnel and pie chart we had to drop categories as they were much larger than the other, thus squashing most categories that were too small to read.

Related reading

]]>
Getting Authentication Access Tokens for Microsoft APIs https://www.bmc.com/blogs/microsoft-apis-authentication-tokens/ Thu, 04 Mar 2021 13:58:59 +0000 https://www.bmc.com/blogs/?p=20334 In order to use Microsoft Power BI or other Microsoft APIs, you have to obtain an access token, also known as a bearer token. This is because Microsoft uses oAuth2, an industry standard protocol, for authentication. (In other words, a simple API key or username with a password is not enough.) In this tutorial, we […]]]>

In order to use Microsoft Power BI or other Microsoft APIs, you have to obtain an access token, also known as a bearer token. This is because Microsoft uses oAuth2, an industry standard protocol, for authentication. (In other words, a simple API key or username with a password is not enough.)

In this tutorial, we explain how to do that.

(This article is part of our Power BI Guide. Use the right-hand menu to navigate.)

Note: We use curl to post data to Microsoft endpoints. That’s like the command line version of Postman. On Mac and Ubuntu, curl is already there. You might have to install on Windows.

Registering Power BI

If you’re doing all this for the very first time, in order to perform both steps of oAuth2 authentication, there’s a Step 0.

You first have to register your application as a means of getting credentials. You do that one time. This generates an application ID and secret key. For Microsoft Power BI, you do it like this:

First, log into the embedding tool at https://app.powerbi.com/embedsetup/UserOwnsData

This is not the same as logging into Azure and creating an application in Active Directory there. You are creating an application on Power BI’s Azure account (if you want to think of it that way).

Next, fill out the screens below. Note that:

  • For the URL, you can use any web page. You will look at the parameters passed to this web page as we show below.
  • Skip the screen that says import content.
  • For API access, click select all.
  • At the end, copy and save the Application ID and Application Secret.

Using oAuth2 for rest APIs

Once you’ve registered, you can move to this step.

Basic authentication is when you need only a user ID and password for access to something.

But Microsoft uses oAuth2 authentication. Microsoft APIs require that you present an Authorization header in order to use the API. Basically, oAuth2 is a two-step process:

  1. Do a POST to login.microsoftonline.com
  2. Take the access/bearer token from Step 1 and pass that to the API in a header called Authorization for whatever API you are calling.

Getting a token (code)

To get the authorization code, click on this URL to open a browser:

https://login.microsoftonline.com/common/oauth2/authorize?client_id=(appid)&response_type=code&response_mode=query&redirect_uri=(url you put when you registered app)&scope=openid&state=foo

Basically, it will take you to the URL you put when you registered the application. But a screen will pop up asking you to grant certain permissions:

  • response_type: code
  • response_mode: query
  • state: foo (Sny value will work here, it’s just a place for free form-data.)
  • scope: openid (You could also add offline_access.)
  • url: We use the same URL throughout but change the URI to authorize and then token later to call different Microsoft endpoints.

Note: Here, the tenant ID is common, not a multi-tenant ID. Common means to retrieve the tenant ID associated with your Azure account.

Now, you certainly could have written some kind of web listener to retrieve the code that Microsoft created. But we will just use the debugger in a Chrome browser to see the query parameter that Microsoft passed to our web page.

When Microsoft redirects you to the web page you indicated, go to the network tab in the browser and click the refresh button on the browser.

Then click on the code field and press Copy as cURL. The code (token) appears as the query parameter code as shown below.

https://walkercodetutorials.com/?code=0.ASsARY...

If you are wondering at this point why the URL is not some URL in Power BI, that’s because you registered the application in Power BI. So, Microsoft knows that Power BI is what you want to use. The redirect URL serves merely as a place to retrieve this code.

Going forward, you would not want to click on the browser every time—this is not how a batch program would work. So look at the prompt setting in the Microsoft Identity Platform reference guide to see how to change that.

Getting an access token

We use curl to illustrate the next steps. Get the access token (bearer token) this way.

The values are:

  • grant_type: Put “authorization_code”
  • client_id: Application ID from above (The dots above hide my actual ID.)
  • client_secret: Application Secret from above
  • redirect_uri: Same as above
  • scope: Same as above
  • url: Note that the endpoint has changed to token
curl -X POST  --form 'grant_type=authorization_code' --form 'client_id=7...5' --form 'client_secret=21dVzEgtjUhfyZS3AJDaH0eMYB0q0ovYeH4YUoa//FM' --form 'scope=openid%20offline_access'--form 'response_type=code' --form 'redirect_uri=https://walkercodetutorials.com/' --form 'code=0.AS...AA' https://login.microsoftonline.com/common/oauth2/token

Returns:

{"token_type":"Bearer","expires_in":"3599","ext_expires_in":"3599","expires_on":"1614591204","not_before":"1614587304","resource":"https://analysis.windows.net/powerbi/api","access_token":"ey….G8CYZQT6t2p5IC1r3E7D_koNqc6h_-f3918o_BP2N0YOweCKKZ7WCw"}

Testing your Microsoft API access

Take the access_token value from the previous step and add it as an Authorization header value as shown below. (You have one hour before it expires.)

This, for example, is how you return a list of datasets in Power BI in My workspace. (That’s the default workspace for free Power BI accounts, meaning for one individual’s use only, as opposed to, for example, an enterprise account.)

Note: myorg does not mean your org. It’s just a placeholder required by Microsoft.

curl -X GET -H "Authorization: Bearer ey….W_A" -H "Content-Type: application/json" https://api.powerbi.com/v1.0/myorg/datasets

That concludes this tutorial.

Related reading

]]>
Creating & Using Linked Tables in Power BI https://www.bmc.com/blogs/power-bi-creating-linked-tables/ Wed, 24 Feb 2021 15:32:00 +0000 https://www.bmc.com/blogs/?p=20270 One good thing about Power BI is that when you add two tables to a dashboard they are synchronized. So, when you click on one table, the linked table filters on that selected value. (It uses relationships between tables to do that, which we’ve previously explained.) Let’s take a look at how this works. (This […]]]>

One good thing about Power BI is that when you add two tables to a dashboard they are synchronized.

So, when you click on one table, the linked table filters on that selected value. (It uses relationships between tables to do that, which we’ve previously explained.)

Let’s take a look at how this works.

(This article is part of our Power BI Guide. Use the right-hand menu to navigate.)

How to create linked tables

To illustrate, below is a report (dashboard) we want to make:

  • On the left, we have transaction categories from our financial accounts
  • On the right, transaction details.

The data is from the transactions.csv data file. (You can download your bank statement if you want to follow along.)

The data on the left is categories. The data on the right are transactions.

To put this in terms of SQL, the data on the left is basically the data:

select category, count(*) from transactions

The data on the right is:

Select * from transactions

We use the relationship wizard in Power BI to join them on the common element category. Then when we put two tables on the dashboard, Power BI uses this relationship to let us drill into the tables by category. In other words, we can see all our office expenses, advertising expenses, travel expenses, etc.

This is what the report looks like when we publish it to powerbi.com:

This is what the transaction detail data looks like:

Group by category

Here are the categories. To make this view of the data we add data the data source transactions.csv a second time, then we dropped all the columns except category. Then we pick group by category.

Now, pick the table visualization and the fields. For the category table we obviously just pick one field, category.

For the transactions table we pick all the transactions fields. Under fields we have the two data sources:

  • Categories
  • Transactions

Resizing the dashboard

Here is what the tables look like when put onto the dashboard. The table and table text are too small and not positioned in the right place when we start. So, grab the edges to move them around and then go to Page View/Actual Size to make them large enough to read.

 

Viewing relationships

Here is the relationship screen. We don’t have to do anything as power BI matches by the common element, category.

When designing the table, before we publish it to powerbi.com, we can test it. We cannot see the layout very well, meaning the full screen size or mobile layout.

But we can click on the category on the left. Then the table on the right updates to show only transactions in that selected category. You could call this synchronized tables.

Viewing full-size

As always, click Publish to Power BI to test the final version. And as we just said, it’s really the only way to see the full-sized screen as Power BI Desktop does not have a very good preview function.

Related reading

]]>
Creating Table Visualizations in Power BI Dashboards https://www.bmc.com/blogs/power-bi-linking-tables-relationships/ Thu, 18 Feb 2021 00:00:03 +0000 https://www.bmc.com/blogs/?p=20207 In this tutorial, we’ll show you how to create relationships between tables in Microsoft Power BI. The good news is that you do this with a click and point wizard—eliminating the need to write any SQL commands. (This article is part of our Power BI Guide. Use the right-hand menu to navigate.) Relationships in Power […]]]>

In this tutorial, we’ll show you how to create relationships between tables in Microsoft Power BI. The good news is that you do this with a click and point wizard—eliminating the need to write any SQL commands.

(This article is part of our Power BI Guide. Use the right-hand menu to navigate.)

Relationships in Power BI

In Power BI, a relationship documents the common elements between tables.

In the example we’ll use here, we have two tables from a sales system: customers and orders.

  • The common element is the customerNumber.
  • The customer table contains the customer name.
  • The orders table contains order amount, product sold, etc.

So, if you want to print the customer name on a sales report, for instance, you need to tell BI what columns link these two tables.

Sample data

To follow along with our example, download this data:

Import the two tables.

Relationship types

From the screen where you imported the data sources, click the Manage Relationships button. BI will guess what elements are in common. Since customerName is in both tables, it picks that. You can edit this if you need to change it.

The Edit button lets you edit the cardinality of the relationship. There are three types:

  • One-to-one. For each row in the left-hand table there is one and only one row in the right-hand table.
  • One-to-many. This is the most common scenario. It means for each row in one of the tables, there are more than one row in the other table. Which table is which depends on which you put on the left or the right. For our orders and customers tables, there are many (more than one) rows in the orders table for each row in the customers table.
  • Many-to-many. Think of this as a one-to-many relationship, but in both directions. For example, imagine a doctor who both prescribes medicines but also takes medicines. Many-to-many is not commonly used.

Click the third icon on the left and you get a visual view of the table relationships.

Now, go to the report layout screen and select the table type layout.

We see that customers and table tables are on the right-hand side. You pick the columns you want on the table from each. We pick the order information from the orders table, then the customer name from the customers table.

Because BI now understands how the two tables are related, it knows how to find the customer name given the customer number in the order table.

The report created is a bit small. Click on Focus Mode on the report to zoom in to make it larger.

Here you can see the Power BI has retrieved the customer name column from the customer table. In other words, it used the relationship to look this up.

That concludes this tutorial.

Related reading

]]>
How To Publish Power BI Reports https://www.bmc.com/blogs/power-bi-publish-reports/ Thu, 11 Feb 2021 14:31:47 +0000 https://www.bmc.com/blogs/?p=20176 In this short tutorial, we’ll explain how—and why—to publish Microsoft Power BI Reports. (Haven’t created a report yet? Learn how to create reports and pie charts.) (This article is part of our Power BI Guide. Use the right-hand menu to navigate.) Publishing in Power BI To publish a Power BI report means to push it […]]]>

In this short tutorial, we’ll explain how—and why—to publish Microsoft Power BI Reports.

(Haven’t created a report yet? Learn how to create reports and pie charts.)

(This article is part of our Power BI Guide. Use the right-hand menu to navigate.)

Publishing in Power BI

To publish a Power BI report means to push it to the cloud so you share it with other users at powerbi.com.

Publishing in this software does not mean publishing it to a web page. But you can do that by loading the report into an iFrame, an item in a web page, onto a web page.

What you can do is controlled by your license:

  • Power BI is free to publish in your own workspace in Office 365 apps, like Dynamo CRM.
  • Power BI Pro, for $9.99 per month, lets you share reports with other Power BI Pro users.
  • Power BI Premium, for $4,995 per month, lets you share reports with anyone, including people with no Power BI license.

Why you need to publish Power BI reports

You use Power BI Desktop to create reports. That is done by a single person on a single computer. In order to share it with other people, and thus make it useful to someone else, you need to push it to the Power BI cloud.

Another reason (or, a kind of a limitation) is that you need to publish the report to see what it will look like to the end user, such as on:

  • Desktop
  • Tablet
  • Phone

How to publish Power BI report

You simply push the Publish button—it’s as easy as that. Microsoft will prompt you to log in.

 

If you are using the free edition you can only publish it to the My WorkSpace workspace.

Here’s what a sample report looks like:

The reports you publish show up in your Office 365 Apps desktop:

That concludes this tutorial.

Related reading

]]>
How To Create Reports in Microsoft Power BI https://www.bmc.com/blogs/power-bi-create-reports/ Tue, 09 Feb 2021 15:01:22 +0000 https://www.bmc.com/blogs/?p=20140 In this article, we’ll show you how to create reports with Microsoft BI. The approach of Microsoft Power BI is a bit different than other products—it’s not always clear. The basic procedure is to repeat the steps below for each widget (graphical object) that you want on the report. You can follow along in this […]]]>

In this article, we’ll show you how to create reports with Microsoft BI.

The approach of Microsoft Power BI is a bit different than other products—it’s not always clear. The basic procedure is to repeat the steps below for each widget (graphical object) that you want on the report.

You can follow along in this article without doing the tutorial yourself. If you do want to work with it, we’ll use the same banking data from .csv files that we used previously, so review that to have some data to work with.

Let’s get started.

(This article is part of our Power BI Guide. Use the right-hand menu to navigate.)

How Power BI works: repeating pattern of steps

You can think of any report as a dashboard. A widget is some kind of visual display: a chart, a table, or just a single metric displayed in a text box.

The basic procedure is to repeat this process for each widget:

  1. Create a data source
  2. Run a transformation (Optional)
  3. Create a query or data model
  4. Pick a visualization
  5. Select fields
  6. Arrange visualization on dashboard

How to create Power BI reports

To illustrate, let’s move through each of these steps. First, we create a data source. That connects to a file, like a .csv, or a database.

Next, you have the option to run a transformation. In our example, we use financial data. We will:

  • Apply a filter to select only negative values (payments)
  • Drop and rename columns
  • Optionally apply a function, such as an aggregation

Step 3 is the natural result of step 2, because you have built up a query in stages.

Alternatively, at this point, you could create a data model. For example, if you have sales and inventory movements in two data sources you can model that. You would create a model to show the common element between tables: product number. (But in the example we’re using, we only have a single data source.)

In step 4, you create a visualization. In this example, we will have a table of transactions. A table is a row and column display. We will also have a single card (like a text box) to show a single number, the maximum transaction amount.

Next, we’ll pick fields from step 4. Finally, in the last step, we’ll position the visualizations on the dashboard.

Now, let’s walk through an actual example.

A hands-on tutorial

Here is the landing page for BI. By default, it shows a pie chart with no data. Notice the three icons on the left:

  • Dashboard
  • Queries
  • Data model

Adding the first visualization

The logical place to start is to select a data source.

The basic procedure is to load and optionally select transform. In most cases, you would want to do a transformation.

For example, let’s click a column, then apply a filter to only have negative values (payments):

Here we select a numeric column, amount. Because it’s a number, we can run a math or aggregation function on it.

We select the Statistics function Maximum:

The result is a scalar (single value), as opposed to a row in a row-column table.

Now click on the new field and give it a meaningful name. Notice that BI keeps track of the steps we have taken.

You’ll also want to rename the query. At this point, BI calls the results of the transformation a query.

Click the close & apply button to close the Power BI editor and return to the dashboard view.

Select the card visualization, then select field maximum from the query maximum.

The card is added to the report:

Adding more visualizations

Now we can add another visualization to show how to build up your report.

We will make a table. Select recent sources and pick the same .csv file. Importantly, we have to go all the way back to the beginning data source because we turned the first source into a query. (We can’t use the query to make a table, since it’s already transformed into a scalar.)

Now we have two queries:

  • wf is a table
  • maximum is the data source or the card visualization

Here’s what the table looks like when attached to the dashboard:

The text looks annoyingly small and graphic-like. It’s not like a spreadsheet, which would be clear and easy to read. (We will show how to clean that up in an upcoming tutorial.)

Finally, move the card over to make room for the table. Select the corner so you can resize it.

That concludes this tutorial. Now, you can begin building your reports with repeating the widget pattern.

Related reading

]]>
Power BI Basics: Creating a Pie Chart https://www.bmc.com/blogs/power-bi-pie-charts/ Tue, 15 Dec 2020 07:43:43 +0000 https://www.bmc.com/blogs/?p=19654 In this tutorial, we’ll show you how to create a pie chart using Microsoft Power BI for desktop. We’ll load some sample data from a .csv file then apply various transformation steps using the Power Query Editor. (This article is part of our Power BI Guide. Use the right-hand menu to navigate.) What’s Power BI? […]]]>

In this tutorial, we’ll show you how to create a pie chart using Microsoft Power BI for desktop. We’ll load some sample data from a .csv file then apply various transformation steps using the Power Query Editor.

(This article is part of our Power BI Guide. Use the right-hand menu to navigate.)

What’s Power BI?

Microsoft Power BI is a business and data analytics service. Its goal is to provide interactive data visualizations and business intelligence (hence the BI) in a simple interface so that anyone can use—from data experts to people who just need the insight.

Power BI has two main options, desktop and SaaS, both of which are free to use on a small scale.

To create dashboards, you’ll need to use the desktop option; the free SaaS option doesn’t have that function. So, you’ll create your dashboards locally, on your machine, then upload them for your users.

Download and install the desktop version, if you don’t already have it. Importantly, Power BI runs only on Windows.

Transform data

Download any kind of financial data if you want to walk through this exercise step-by-step. Or just read through it—the tutorial is short and uncomplicated.

We will use some expense data from a debit card. We need to:

  • Filter out positive numbers. (We want only expenses, not payments.)
  • Split the text by the delimiter issued by to extract the vendor name from description.
  • Sum expenses by vendor.

Create a new Power BI report

Open Power BI Desktop and create a new report. (A better name might be dashboard. Microsoft uses both terms.)

Add a data source and import a .csv file. Instead of pressing the Load button, though, press Transform. That launches the Power Query Editor, which lets you filter, parse, and convert data.

If you use a .csv file with headers select Use First Row as Headers:

Choose columns

The data that we’re using has columns that we don’t need. You can remove those here:

Now, the data we have does not have any categories and the vendor name is buried in transaction id issued by vendor name.

So, let’s use the text column function to extract the text after the delimiter issued by. This is simpler than having to handwrite a formula, as you would, for example, in Excel. (The Power Query Editor also works in Excel.)

Enter the delimiter text:

Power BI will replace the description column and not create a new one. That is a nice feature. If you were using Excel, for example, it would put the results in a new column. So, Power BI saves a step.

Group by description

Now we’ll sum the amount by vendor.

First, let’s make a mistake on purpose—so we can learn how to undo it. Select Group by and replace count with sum and pick the column description. Of course, it makes no sense to sum a text field, but do that to create an error.

Undo & fix error

This is a nice feature in Power BI. There is no undo button—there’s something better. Power BI keeps track of each step on the right-hand side of the screen. Simply delete the last Applied Step and it undoes our mistake.

Now fix it by selecting Group by again, but this time select column amount.

Filter positive values

Amounts bigger than 0 are payments. Amounts less than 0 are expenses. We want only expenses, so apply this filter. It does not ask which column since we’ve already done a Group by amount, we only have one sum column.

Now close and apply.

When we load the data into a visualization we will see that it is too crowded with too many vendors. So, we can filter again and drop any vendors whose expenses are less than 100.

And now, you can create a visualization by picking it and the columns to go on the visualization. You could switch the x-y axes in the case of a bar or scatter chart. With Power BI, you can’t do anything illogical, such as picking four columns in a chart that only supports three.

Here is our pie chart. The resolution is not good, unfortunately, which I think is a drawback of Power BI.

To view it a little better, click the filter, visualization, and fields tab to move those out of the way. Then click fit to width to get a better view of the chart. It’s probably small as Power BI is designed to have multiple charts on one dashboard.

That concludes this Power BI tutorial.

Related reading

]]>