If you have been using the MICROSOFT EXCEL software for some time, you must have heard or read about the word POWER QUERY.
POWER QUERY IS A DATA SHAPING TOOL WHERE WE CAN BRING THE DATA THROUGH A CONNECTION FROM VARIOUS SOURCES, DO SOME SHAPING SUCH AS REMOVING ROWS, COLUMNS, CHANGING DATA TYPES, TRIMMING THE DATA ETC. AND GET IT FINALLY FOR THE ANALYSIS IN OUR MAIN SOFTWARE SUCH AS MICROSOFT EXCEL OR MICROSOFT POWER BI .
Power Query tool, in fact, has immense powers to shape up the data in the way we want.
We’ll cover a lot of practical problems to sort them with the help of the POWER QUERY.
IN THIS ARTICLE, WE ‘LL LEARN TO CONCATENATE COLUMN DATA INTO A NEW COLUMN
WHAT IS CONCATENATION
CONCATENATION or TO CONCATENATE simply means the process of sticking together.
We use this process with the use of function or operator in Excel to stick any two or more texts, numbers or numbers and texts.
1 concatenated with 2 will result in 12.
Hello concatenated with Sir will result in HelloSir. [ We didn’t put any spaces in between ].
HOW TO CONCATENATE CUSTOM TEXT TO COLUMNS IN POWER QUERY
We will take an example to understand the process of concatenating the columns to create a new column.
Let us take a table for the example which we will load from the EXCEL and transform it so that its loaded into POWER QUERY EDITOR.
The table for the example is shown in the picture below.
Read the article mentioned above.
In the navigator, use TRANSFORM DATA and the table would open in the POWER QUERY EDITOR.
DATA FOR THE EXAMPLE
FOLLOWING PICTURE SHOWS THE DATA FOR THE EXAMPLE.
We have the sales data for 7 week from the different continents.
We will concatenate the COLUMN1 with the custom text WAS GREAT. [ The text will become WEEK 1 WAS GREAT, WEEK 2 WAS GREAT…]
STEPS TO CONCATENATE CUSTOM TEXT TO COLUMNS IN POWER QUERY AND CREATE A NEW COLUMN:
- Select TAB ADD COLUMN.
- Click on CUSTOM COLUMN button.
- The location is shown in the picture below.
After clicking the CUSTOM COLUMN button, CUSTOM COLUMN DIALOG BOX will open.
The picture below shows the CUSTOM COLUMN DIALOG BOX.
The dialog box asks for the COLUMN NAME, Asks for the FORMULA [ which will derive the values in the new column ] and provides the available column names of the current table.
THE NOTIFICATION IN THE LOWER PORTION OF THE CUSTOM COLUMN DIALOG BOX SHOWS THE STATUS OF THE SYNTAX ERROR.
For our example we put the NEW COLUMN NAME as CUSTOM.Put the formula for the concatenation as
=[Column1]&” WAS GOOD”.
We don’t need to write the column names. Choose the column names from the available list on the right, select it and click INSERT button at the bottom. The name will appear in the FORMULA AREA.
- Check the syntax notification at the bottom. If it says NO ERROR as in our case, click OK.
- The new CUSTOM COLUMN will be added on the RIGHT of the table. The location can be easily changed by
- RIGHT CLICK>MOVE>LEFT, RIGHT, TO THE END OR TO THE BEGINNING.
PROBLEMS AND SOLUTIONS
I AM GETTING ERROR WHILE CONCATENATING IN POWER QUERY
If you already tried to concatenate the columns in the EXCEL STYLE, you might have ended up with an error in the values.
That is because of the reason that we can’t concatenate just any format but only TEXT FORMAT.
All the columns being concatenated should be in the TEXT FORMAT.
For our example,COLUMN 1 is already text but
COLUMN ASIA and COLUMN AMERICA [and other columns too ] are in the number format.
So we need to convert the format to the text format first.
FOLLOW THE STEPS TO CHANGE THE FORMAT OF THE COLUMN IN POWER QUERY.
- Right click the column header ASIA.
- The following menu will appear.
- Go to CHANGE TYPE and choose TEXT.
- Repeat the process for COLUMN AMERICA also.
In this article we learnt about concatenating the text to the columns using power query.
Click below to learn about concatenating two columns in POWER QUERY.