kohera-logo-regular.svg

Import text by example in Power BI reports

If you want to see the topic of this blog in action, then watch our free webcast on the latest features in Power BI where we discuss this new capability of Microsoft’s BI tool by clicking here.

Weirdly formatted files, we’ve all had to import them into our reports at some point. Despite knowing what data we want to extract from the file, until now there was no easy way of showing that to the Power Query Editor. Of course, it was possible to extract the data, but it took quite some time to figure out how to get this done properly with the tool. Luckily, Power BI has new option that might make our lives easier: import text/CSV by example. We’ll show you how to use it in this blog.

Our starting point

We have a demo file called Bikes.txt with the following content:

The content is not that complex. We can see at first glance what and how we want the data to be extracted from the file.

 

Biketype 2013 2014 2015
Tandem 7 6 5
BMX 8 1 6
Bike 6 5 7
Electric Bike 9 3 12
Mountainbike 2 4 10

 

From a technical point of view, however, it is a bit more complex since multiple different separators are used. First a tab is used and later on a semicolon. In the past, we had to import the file using one of the two separators and then start splitting the columns again using the other separator. Or another method like that.

Using ‘import text/CSV by example’

With ‘import text/CSV by example’, there’s an easier way to get the right data sorted into the right column within our Power BI report. We start the same as always to get data from a CSV or text file.

After selecting the file, we get the usual window showing how Power BI interprets the file layout. Here we immediately see that we have an issue caused by the different separators. Changing the delimiter to ‘tab’ might improve the situation, but that still leaves some columns not properly split.

Now let’s have a look at what happens when we click on the new button in the bottom left corner ‘Extract Table Using Examples’.

A new window pops up where we have the option to manually input the data the way we want it visualized and separated. After filling in a couple of values, Power BI autodetects how it should handle your imported data and fills in the other values. In this example the headers and first line where sufficient.

If you need more information about what Power BI did behind the scenes, you can click on ‘Transform Data’. Then, in the Power Query Editor, we see a breakdown of the multiple steps Power BI took to reach the desired result. If all looks good, we can then let Power BI load the data using these steps. Another step closer to making our lifes easier!

Parameter sniffing solved with new Parameter Sensitive Plan Optimization feature

If you’re someone that works a lot with Microsoft SQL Server, there’s no doubt that you’ve had issues with an issue called “Parameter sniffing” before. Up until now, you had...

Creating maps with R and Power BI

The possibilities are infinite when it comes to creating custom visuals in Power BI. As long as you have creativity and knowledge about the right programming language, you can let...

Sending monitoring alerts through Telegram

What if you could get the ease of phone notifications for whatever monitoring alerts you need? Then we have a solution for you with the app Telegram. Some of you...

Send mails with Azure Elastic Database Jobs

The DatabaseMail feature in SQL Server and Managed Instance is widely used by many professionals. But what if you want a similar functionality in Azure SQL Database? There are options,...

Sorting matrices in Power BI

Recently I worked on a Power BI project for a client. They had a SharePoint site where they regularly published articles and wanted to pour view data into a report...

The world of data is evolving

The data landscape has changed dramatically over recent years. In the past, we mainly heard that we needed to do as much as possible “cloud-only”—but this trend has become more...