kohera-logo-regular.svg

Import text by example in Power BI reports

Vector_BG.png

Import text by example in Power BI reports

Vector_BG.png

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.

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!

 

 

 

Photo of successful woman coder hacker web creator sitting armchair comfortable workspace workstation indoors.
The hurdles and pitfalls of moving or migrating a System-versioned temporal table cross database
Maybe you already have your own way of doing this and are wondering about alternative methods, or maybe you are...
Group of computer programmers working in the office. Focus is on blond woman showing something to her colleague on PC.
Updating your Azure SQL server OAuth2 credentials in Power BI via PowerShell for automation purposes
The better way to update OAuth2 credentials in Power BI is by automating the process of updating Azure SQL Server...
2401-under-memory-pressure-featured-image
Under (memory) pressure
A few weeks ago, a client asked me if they were experiencing memory pressure and how they could monitor it...
2402-fabric-lakehouse-featured-image
Managing files from other devices in a Fabric Lakehouse using the Python Azure SDK
In this blogpost, you’ll see how to manage files in OneLake programmatically using the Python Azure SDK. Very little coding...
2319-blog-database-specific-security-featured-image
Database specific security in SQL Server
There are many different ways to secure your database. In this blog post we will give most of them a...
kohera-2312-blog-sql-server-level-security-featured-image
SQL Server security made easy on the server level
In this blog, we’re going to look at the options we have for server level security. In SQL Server we...