Skip to main content

Guide to power query editor

Are you spending a big chunk of your time cleaning the data in excel? If yes then this blog is for you. All the cleaning and transforming of data can be achieved in Microsoft Power BI. Power BI offers a wide variety of options to clean your data. Power BI comes with a power query editor where you can play around with the data and I consider it as an ETL tool where you can transform your data according to the needs.

We have discussed the data cleaning process in the last blog and in today's blog the focus will be on transforming data and the features that the power query editor offers. These steps are solely subjective according to the data type and to your needs. I am highlighting 6 steps to transforming the data. I am working on the sample superstore data. So let's get started!!!!

  • Removing columns and rows- We are aware that the datasets can have a lot of unwanted columns and rows. To get better insights you need to get rid of it. To do so you need to select the column. If you need multiple columns at once then hold down the Ctrl key and select all the columns. On the home ribbon, you can find the remove column pane. Considering this dataset I am adding the returned data along with the order summary and you can see in the second picture that the headers are in rows. You need to select the tab "Use the first row as headers".



  • Checking the data type of each and every column because there are times where the columns are assigned with the wrong data type and can hamper the visualization. To do so if you toggle around every column on the left corner of every column you can find the data type assigned to that whole column. To change it you need to click it and you will get different options to select from. 

  • Splitting the columns- There are several instances where you need to split the column for eg. you need to separate the first name and last names of consumers then this is the befitted option. This is similar to text to columns in excel. In this dataset, I am finding out the acronym for different categories which is present in the Product_ID and we will split the acronym from there.


  • Replacing and removing null values- It is quite common to find a lot of null values when you are dealing with such big datasets. To get rid of such values you need to select one of the null values in a column and right-click where you get options to replace and remove such values. In this dataset, I am replacing the null values with a text.

  • Merging and appending the data- This feature is most discussed in the Power BI community and users can get confused at times whether to use merge or append. When we talk about the merge you need to combine the queries via a common column. It's not the case with appending queries if you need to add extra rows to your existing query then use append. In this case, we are merging the order summary query with return status, and Order_ID act as a common column for this. To do so you need to select the merge queries pane in the Home ribbon. It will open up a new toggle where you need the common column and the type of join you want. Normally I use left join.




  • Unpivoting the column- This is one of the most widely used features of the power query editor. It is quite similar to the Transpose formula in excel. In this dataset, we are adding the US population numbers. To do so we are scraping the data from the web


You will land up with the population data where you can remove unnecessary columns as suggested previously. After that, you need to switch to the transform pane where you can find the unpivot column. In that tab select the unpivot other columns

These are some of the basic steps which I followed to transform the data and you can observe the difference in the quality of insights you are going to generate if you implement such techniques. I haven't explored many features such as creating a data query that will help you to utilize all the time intelligence functions. Also, one great piece of advice would just check all the applied steps in the right of every query and you can undo any step with just one click. Power BI is very intuitive in nature and you won't find it difficult to try out all the offered features.  



Thanks for Reading  Let's connect on  LinkedIn.


Comments

Popular posts from this blog

Ultimate Beginners Guide to DAX Studio

There are zillions of external tools available with Power BI but DAX Studio is one of the most commonly used tools to work with DAX queries. It is a perfect tool to optimize the DAX and the data model. In this blog let's shed some light on the basic functionalities that can take your report to the next level. ARE YOU READY?  To start you will need the latest version of the DAX Studio. You can download it from their website . Don't worry you don't have to pay for the license. Fortunately, DAX Studio is a free tool As a BI Developer, I am using DAX Studio regularly. Based on my experience I use it for several purposes but in this blog, I will highlight the most common ones. Extracting a dump of all the measures used in your PBIX. Why do we need to do this? It can be used for documentation purposes also sometimes we try to reuse the DAX and such a dump comes in handy in this scenario. How to achieve it? Open the DAX Studio it is located under the external tools once you open t

Append v/s Merge in Power BI

Let's discuss another problem of the week. As a Power BI user, there are times when you want to combine queries. What are the ways to do so? In most cases, you can attain it by using either append or merge and both serve different purposes. Let's understand what do these terms mean in Power BI and how they are functionally different from each other.  It is quite common to get data from various sources and you need to combine those data depending on a particular column which is common in both tables so that you can add extra information or column to your big table. In such cases, we use merge queries. How to perform merge queries? For instance, I am considering Sample Superstore data and we will merge the returns table to the order table. You will find both merge and append in the home tab in extreme right in the power query editor. ProTip - You will find two options when you click on the drop-down in merge which are merge queries and merge queries as new. When you use merge que

Use Relationship in DAX

Data modeling is an essential part of creating perfect visuals. While creating complex data models there can be a case where you can find an inactive relationship represented by dotted lines and it occurs because you already have an active relationship between the two tables. But as a developer, you need to use both the relationship. How can it be done? You can use "Use Relationship" in such cases. Use relationship can be added to your DAX and act as a modifier or enhancer for calculation. It activates the inactive relation. But make sure you have an inactive relationship in place before using the use relationship function. Let's see how it works on Sample Superstore data. In my fact table I have two dates- Order date and Ship date. I am making the two relations between my date table and fact table. The relation between the sample superstore (date) to date table (date) is active while the relation between the sample superstore (ship date) to date table (date) is inactive