Transcript

Use with ChatGPT / Claude Auto-scroll A

1. Introduction & Loading Data into Power Query

Introduces the Power Query masterclass, explains ETL (extract, transform, load), shows where Power Query lives in Excel, and demonstrates converting data into an Excel table and loading it into the Power Query editor.

0:00 - 0:47
Our query can save you 20 hours every single week and it can change the way you work.Now, why I'm saying this?Because I used to waste hours every single morning until I discovered Power Query.And that's why if you're wasting your time every single morning, you need to learn Power Query.Now, here's the thing.There are millions of Excel users who are spending 80% of their time just in managing the data instead of analyzing it.And if you really want to be a top data analyst, you need to flip this ratio.You need to spend 80% of your time in analyzing data.And that's why you need to learn Power Query.Now think about this.You have a data like this and you want to transform this data from this to this.How would you do that?Which method you would use and which formula you would use?
Well, if you really want to go with the formula, you need to write a formula, a complex formula like this.But in Power Query, you can do this with a few clicks.Just a few clicks.And that's why you need to learn Power Query.Now, in this master class, I'm going to take you from very basics of Power Query to advanced step by step.We're going to learn every single thing that you need to learn Power Query and save your time so that every morning you are just focused on your analysis, not on the tussle of data.So make sure to download all the sample files and now let's get started.It's time to understand what is power query.And if I have to tell you in simple words, Power Query is Microsoft's ETL.Now ETL means extract, transform and load.Now think about this.
You have an Excel workbook on Google Drive and with Power Query, you can extract data from that Excel workbook.Once you extract that data, you can load that data into the Power Query editor and you can transform it.So that's the second step and after that once you complete your transformation you can load that data in your Excel workbook that is on your system.So these are the three steps you connect the data you extract the data and then you transform that data and then you load that data in your workbook for further analysis and further reporting and everything.So in the next chapter we're going to learn about power query editor which is the most important point to start using power query.So let's have a look.This is the point where we're going to use power query and start transforming our data.So the first question is where is power query in our Excel.
So for this you need to go to the data tab and here you have this small section here that says get and transform data and here you have all the options listed to get data into the power queryeditor.So if I just open it for you, you can see there are further categories where I have different sources to get data into the power query.I have from files, you can get data from a workbook, from a text, from XML, JSON, PDF or even from folder.So everything we're going to learn in this master class in just a few minutes.And then I have other sources like I want to get data from web, I want to get data from table and all the other sources that you can think of that you want to connect with Power PD.And here you have this small button that says get data preview.
And it gives you this complete look at all the sources that are available to get data into the power query.You can choose any of these sources for getting your data into the power query.But in my case, I have this data into my worksheet already.And now I'm going to load this data into the power query editor.When we want to load our data into the Power Query editor, there is one important thing that we need to understand and that is to convert our data into an Excel table.So if I just select any cell from my data and then go to data tab and click on this option that says from table or range and I click on it before loading the data into the power creatorit gives me this option to convert this data into an Excel table and that's why I'm saying that converting your data into an Excel table is must load it into the power creator.
So you already have this option.You don't need to go to, you know, the table option to convert it into an Excel table.But I still do it manually myself and I'll show you the reason for this.So if I just use this keyboard shortcut Ctrl T, it gives me the same dialog box that says convert your data into an Excel table.I'll click okay and my data is now an Excel table.Now here's the most important thing.When I do that, when I convert this data into an Excel table myself, I get this option table design and then I can change the name of the table before loading to the Power Query editor.So, I'll say sales data and hit enter.You can do it in the PowerB editor as well, but I use this practice to name my table before loading to the Power Query editor.
So, now my data is ready.My table is ready.I'll go back and go to get data and get and transform data.And this is the button that I need to click.The same option is also within this get data dropdown.So you can go to other sources and it says from table and range or you can just simply use this because you will use this option a lot when you start using power query.That's why this option is here already.You can click here and here we have our data into the power query editor.

2. Power Query Editor Tour & First Transformation

Walks through the Power Query editor interface including applied steps, ribbon, right-click menu, and M language formula bar, then performs a first filter transformation and loads data back with close and load, showing dynamic refresh.

Now it's really really important to understand the user interface of Power Query editor because everything that we're going to do with Power Query will do in this editor.Let me just start with this section that is on the right side of your window.This is the applied steps.We have all the you know settings for the queries but the major part is applied steps.Let me tell you about one of the beauties of Power Query.Whenever you do anything in power query that activity let's say you delete a column you add a new column you change something in in a column or you replace some values that activity will be listed as a singlestep and all those steps will be listed here you can see this is the first step we which power query performed for me to getting data into the power query that is like sourcing the data and that's why
I have this step here that says source and then power query identified the type of the data in all the columns by itself and And that's why I have this changed type step here.And now when I start doing anything, let's say if I delete this column, I'll get that step here.And if I just, you know, change formatting of this column, I'll get that step here.And if I just, you know, split date and time here, that step will also get listed here.So everything that I'm doing in a sequence will be listed here in this section in a sequence in that exact sequence.That is one of those beauties of the power query that you get everything listed in a sequence in your power query editor.Now let me go ahead.This is the main section where we have our table.The table which we have just loaded from our worksheet.
Now here's one thing that you need to understand about power query.Even though the power query editor looks like Excel, we have you know ribbons.We have all the options listed exactly the Excel worksheet window and we have this formula bar as well.But there is one thing that is completely different in Power Query than Excel and that is how we change the values.If you want to do something in Power Query, let's say you want to change a value.Let's say you want to change this bank value with the name of the bank.You cannot do it for a single cell.You need to do you need to apply this replacing of value to an entire column.Everything that you do in PowerBI starts from a single column.You can do it for multiple columns.You can do it for entire data but you cannot do it for a single cell or multiple cells.
That replacement will be applied on on a single column at least.So that's one big difference between working in Excel and working in power query.So we have this data here.Let me just come back and this is the section which says queries.If you have multiple queries in your in your power query, all those queries for that particular workbook will be listed here in this section.We'll see this when we use power query more and more when we'll have multiple you know queries we'll see all those queries are listed here.Now after that just like Excel we have this ribbon here that gives us all the options that we can use in power query to transfer my data and believe me you'll find it so amazing when you find allthe options that you can use in power query to to transfer your data.
All those options are listed here.Let's say if I want to you know split a column here is the option.If I want to group my data, the option is here.And if I want to, you know, just to replace some values, I need to go to the transform tab.And here is the replace values option.So all these options are listed here.But apart from that, there is one more hidden thing that we have in the PowerPoint editor.And that thing we are going to use a lot in this masterass and that is the rightclick menu.When you select a column and then you right click, you get this rightclick menu where you have more than 20 options to transform your data.So you're going to use this right click menu a lot in power query.Now last but not the least we also have this one formula bar here just like Excel.
This is the formula bar but it has a different kind of language here that is happening in power query.So what happens is whenever you do anything in bubble query you you change something you try to add a new column whatever that is listed as a steps here on the right side but also as a coding languagethat is the M language or power query at the back end.So if I just go to home tab, I can show you this is the option that says advanced editor.And here you have your M language that is getting generated at the back end by Power Query.And this is the formula bar where you have that formula or that language for you that is getting generated by Power Query at the back end.Now we're going to focus on a small transformation that we want to do with the Power Query.
And that transformation is I want to filter my data only for internet and software.So when I click okay, my data is filtered.I only have category software and internet.And now you can see at the very right of my window where I have applied steps, it says a new step that is filtered row.So that's how power list everything one by one as per your activities.And if I just click on the delete button here, it will undo that step for me.And I need to do it again.Then I'll go to internet software.Click okay.And that filter is applied again.Now the third most importantly we get our data into the power query editor.That was the first step.And now we made this small transformation.This is the second step.And now the third most important part of this this entire process of transforming our data.
and that is to load our data back to the power query editor.So what I'll do, I'll go to my home tab and here I have this button that says close and load and there is a small drop down here that says close and load and close and load two.But for now we're going to focus on close and load two option and I'm going to click on it and it instantly load my data into my workbook in a new worksheet but only for the filter that Ihave applied.So I have software and I have internet categories only.Let me show you the beauty of Power Query again.Let's say if I add one more entry here.
Now if I go to my new table where I applied that filter using power query and try to refresh this this table, you can see I get the new entry automatically.I don't need to do anything again to just to open the power editor and do all those things.My query is ready and it will always give me data based on my transformation.And now if I go back to my new table and try to refresh this time I don't get the new entry because that entry is not for software or internet cuz that was the filter I had in thepower query editor.

3. Importing Data from External Workbooks

Connects to an external Excel workbook using the navigator dialog, performs transformations like duplicating columns and converting dates to month names, and explains how to update the source file path when a workbook moves.

Let's start with the file that I have in the workbook.You can download this file from the link in the description.And if I just open this file and to show you I have this small table here.And in this workbook, in this entire step of getting data from external workbook, let me remind you two things that we have here.We have this table and this table is an Excel table.I have applied an Excel table to this this particular sales data.And if I go to table design, you can see the name of the table is t sales and the worksheet name is sales.So we need to remember two things.The name of the table and name of the worksheet.So let me just close it from here.And here is my blank workbook.So I'll go to the data tab and from there I'm going to click on get data and then from file.
Now in the from file I have a list of options that I can use to connect different kind of files.I can connect an Excel workbook, text or CSV.I can connect an XML, JSON, PDF or even from folder.So we're going to learn all of these things in the later section of this master class.But right now let's concentrate on our Excel workbook.So I'm going to go with Excel workbook and it gives me this dialog box.I'm going to select the file that I want to import.Click on import and within a few seconds I get this navigator dialog box.Now this navigator dialog box is very very important to understand.Now I told you to remember the name of the table and the name of the worksheet.This is the workbook that I have just connected and you can see I have the table here with the name T sales which is the name of the table and I also have this name that says sales which
is the worksheet.Now here is one conflict that can be confusing for you.We have table and we have the worksheet.But data in these two options is same is exactly same.What is happening here?Power query can identify data in two ways.One is using the name of the worksheet and one is by using the name of the table.If you have a table in your workbook in your worksheet, Excel can identify the table automatically without you know you specifying hey I want this table and that table.So it can identify the worksheets, it can identify the tables.And that's why for the same data I have two identifications.One is by the table name and one is by the worksheet name.But it's always better to go by the table instead of the worksheet.So I'm going to select my T sales that's the table.
And here I have these two buttons transform data and load that I'm going to choose.Now what is the difference between load and transform data?Even the load button has further options.one is load and one is load to.When you use any of these two options, load or load to power query will not open the power query editor for you.It will get the data from that file and load it in your workbook.If you don't want to make any transformation, you can use this option.But in our case, we are going to make a few transformations.So that's why I'm going to click on transform data here.And it will load Power Query editor with my data from the external workbooks.Here I have the data and now we're going to make a few transformations in this data.We're going to change a few things and we will then load this data to our worksheet.
As you know these are the applied steps.The steps that we do in Power Query.All the steps will be listed here.Now what I'll do I'll right click on this invoice state column and I'm going to use this option that says duplicate column.And the moment I click on this option, I get this exact same column at the end of the table that says invoice date copy.So my duplicate column is here.The next thing is to rename this column.So I'm going to double click on the header of the column and it allows me to edit this name of the column.So I'm going to say month.And now I want to convert these dates into months.Again right click on the header go to transform and from there month and I have this option that says month of name.Now here you can see how easy it is in power query to do these kind of transformation because in Excel if I want to convert uh date into month name I need to use you know formulas I need
to write the formulas or I need to change the formatting of the of the column.But in Power Query you can do it with just a few clicks.So I'm going to click on this name of the month and it will instantly convert all the dates into the name of the month.Now my transformation is done.The only thing that I want now is to move this column after the invoice date column.I can do two things here.The one is just select this entire column.Hold this column from here using the left key of my mouse and then drag this column all the way after the invoice date column.So that's the one option I have.Other than this, if I just delete this step from here, I'll right click on this column and then I'm going to say move and I'm going to say to beginning and it will move my column at the very
beginning of the table.But that's not something I want.I'll take this column from here again, drag and drop and drop it after the invoice date column.So my month column is on the right place.But you can see for two different steps I have performed.The one is moving to the beginning and then dropping it after the invoice date.The step is only one here that says reordered column.So now here Power Query is smart enough to identify two two steps that I have performed in a sequence that these two steps are identical and that's why we have only one step here that says reordered columns.So my transformation is done.Everything is done.Now it's time to load my data into my worksheet.So I'll go here, click on the flows and load and my table is here.Everything from the external workbook now I have here.
But the extra things that I have is my transformation that I have done using the invoice date column into the month column.Now to test how dynamic Power Query is, let me just minimize this workbook and open the external workbook, the source workbook that I have.And here let me just change a simple value.can just choose my own name and Ctrl S.And when I select any of the cells here and just right click, you see the name of the customer is now changed.So that's the beauty of Power Query that you don't need to, you know, do anything again and again.Once you connect your query, once you perform all your transformations, it will refresh your data whenever you refresh and there is any change in the source data.But now there is one more thing that you need to understand because you know how to connect an external workbook, how to do all the transformations.
But there's one more important point that we have in this section.Now let's say this workbook that I have on my desktop.If I want to move this workbook from one, you know, from desktop to a different folder on any different drive.In that case, do I need to perform all those steps again for my query?Well, answer is no.So once you change the location of your file before refreshing your query because that query will show you an error.In that case you need to do one thing.You need to go to the query and click on edit.You can also edit your query from the queries and connections pane.You can just right click and say edit and it will open the same query for you and you have all the steps here which we have just performed.Now if I just go to the source step, you can see I have this small very tiny settings icon at the right side of the step.
Now this icon says there is kind of setting that you can change in this step.So what I'll do, I'll select the source step and I'm going to double click on it.And instantly it shows me this dialog box where I have this file path and I have also this type of opening a file.how I want to open this file as Excel workbook or any other workbook and this is the point this is the input bar where I need to change the location of the workbook.So if I just go to desktop show you how to get the file path you can right click and then you can use copy as path.Even if you need to change the workbook you have one workbook connected and now you want to change the source workbook entirely not just the location but the file as well.
In that case you just need to get the path from that file and then come back to your power query.Paste that path here.Remove these double quotation marks and click okay.and it will change the entire source data for you.The only thing that you need to take care that the structure of the file, the data that you have in that file or new file or even the same file to a new location needs to be same becauseall these steps follows a kind of structure that you have used in your data.So that's the most important thing when you changing the path of the file.

4. Extracting Tables from PDF Files

Shows why copying tables from PDFs fails and how Power Query solves it, then covers an advanced real-life example of combining four tables from a multi-page PDF using append queries.

Now let me show you one big problem here and why we need to extract tables from PDF files using power query.If I go to this PDF file that I have here, it's a small table expense sheet and when I try to copy this table from here, first of all, I cannot copy it entirely.But even if I just, you know, use the keyboard shortcut Ctrl C and then go to my Excel workbook and try to paste it here, I don't get the table in the right format.Even if I just go back and say Ctrl A and then C and try to paste it here, I still don't get the right format.So that's the one big reason that you can use Power Query, which is an effective solution to get a table or any kind of table data from a PDF.So what I'll do, I'll go to data tab, go to get data and from file.
And here we have all the you know options to connect different files here.So I'm going to go with from PDF and I would click on this expense sample PDF.Click on import and within a few seconds I have this navigator dialog box here.Power query also use two different ways to identify table from PDF.The one is using the exact table that we have.So if you have four different tables, let's say you have four different tables in your PDF, AOKI will show you all those four tables in four different options.table one, table two, table 3 and table four.But apart from that, power query also identify pages where you have those tables.But there is one big problem with going by page.You can see here if I just go to the table, you can see I have the exact table.I have the you know headings, I have dates and everything that I have in the original table from the PDF.
But when I click on the page 001, it gives me the table.It gives me all the details.But along with that in the first row I have the name of the PDF which is the heading of the PDF which makes this table a little tough to use in further any kind of reporting or analysis.So that's why I'm not going to go with the page 001.I'm going to go with table 001 and then I'm going to say transform data and then I'm going to click on transform data to get this table into the power query editor or I can just click on theload button if I don't want to make any transformation in this table.So right now I'm going to go with transform data here and within a seconds I get table from my PDF into the power query editor.Now here I have my data from the PDF and you can see I have four steps here.
The first is source and the navigation and then promoted headers and then change type.Now this is one simple transformation that I want to do in this PDF the data from the PDF is to change the formatting of the amount column.So if I just select this column, you can see the format is decimal number and that is something I don't want.I want to have the format of currency.
When I click on it, it asks me a simple question if I want to know include this change of formatting of the amount column into the current step that I have or I want to add a new step.So if I just click on add new step it will add one more step here and change my type of amount column into the currency or I can just go back say currency and say replace current.So it will merge that you know that changing that data change into the current step of change type.So this is the table I wanted from the PDF and I just want to get it into my Excel workbook.So I'll go to close and load.Click here and here I have my data from the PDF file.Now let me show you an advanced example here.This is advanced but I'm adding this at the very beginning of this master class because this is so relatable with the PDF section where we extract data from a PDF.
This example is basically a real life example.I have this another PDF here that you can download from your sample files the link in the description.And when I open this you know PDF file you can see I have multiple tables here.I don't have a single table but I have four different tables.It's a monthly sales report but the pages are four.Now what happens is I want to have all these four tables into a single table while connecting PDF into my Excel workbook.I want to combine these all these four tables into a single table and then get into my Excel workbook.So for this we need to follow simple but a few extra steps.So I'll go to my Excel workbook again and from data again get data from file and then go to ROM PDF and this is the file that I want to connect click import and again I'll get the navigator
and in the navigator here I need to do a few extra steps.First of all I'm going to click on select multiple items here.So it's a tiny option here but very very useful.And you can see I have four tables here because we have four tables in the PDF and we have four pages also.But as we have learned, we are not going to go with the pages.We're going to go with the tables.So I'll select the first table and then select the second and third and then fourth.But here there is one thing that you need to understand and that you need to check whenever you're using these steps.Make sure to verify that all the four tables even if you have 30 tables, 50 tables, all those tables should have the same structure of the data.And that is very very important.
So my all the four tables are selected and now I'm going to say transform data.
In my power query editor, I still have these four tables in four different queries.Now here the actual transformation starts.I need to use a option that is called append queries.I'll go to home tab and here I have this option that says append queries.So I'm going to click on this small drop-down here and I'm going to say append queries as new.And here I have this small dialog box that says two tables.That means if I want to you know append two tables but I have four tables.So I need to go with this option that says three or more tables.Click on here.And I already have first table here.So I'm going to click on the second table.Click add.And then the third table.Click add.And the fourth table and click add.So this is the sequence of tables that I'm going to you know merge with the append queries.
And now I'm going to click okay.And in the new query here that says append one, I have data from all the four tables here.And that is so so amazing that without doing anything complicated, you have data from all the four tables from that PDF that is near to impossible to copy from the PDF to Excel workbook manually.So the next thing I'm going to right click on this new query that I got here and I'm going to say all tables from PDF.
We need to do one final step and that step is to get the combined data in the workbook not from the separate tables.So for this when I go to close and load I will not choose close and load but I will choose close and load two.And here I'm going to say create only connection.So now I'll right click here and I will say load two and I'm going to say table and click okay.And here I have data which is on a different point but let me just move it from here.So this is my data from all the four tables from the PDF.And if you change the PDF, if you change anything in the PDF, even if you replace the PDF with a with a new PDF, it will get the data from all the four tables from the PDF.

5. Getting Data from Web Pages & URLs

Demonstrates three web import examples: a static US states population table with cleanup steps, a dynamic stock data table set to auto-refresh every 30 minutes, and loading a workbook hosted at a URL.

Now let's start with three different examples to understand how to get data from web using powering.So the first example is this page where I have data for US states by population and I have this this table here which is a static table and after that I have this stock data here which is atable again but this table is a dynamic table and the data in this table updates itself pretty much multiple times in a day.So I'm going to get this data from this web page into my Excel workbook.And then I have this URL where I have a file saved and I want to get data from that file that Excel workbook into my current Excel workbook.So we're going to see all these three examples one by one.I'll start with this web page and I'm going to copy the URL and then I'm going to go to my Excel workbook data tab get data and this time I'm not going to use any option from file the
drop-own from file because there is no option to get data from web.So what I'll do, I'll go to this option that says from other sources.And then here I have this option.So I'm going to click on it.And in this dialog box, I'm going to paste the URL.Click okay.And it will take a few seconds to show me this navigator dialog box.Now Power Query is pretty smart enough to identify all the HTML tables from the web page.You can see here I have this table one which is HTML table that I want.And then I have some suggested tables which are basically other tables and other data from the web page.But I don't want these tables.So I'll simply go with the first one that is the suggested table or I will go with this first HTML table.So this table looks pretty much fine to me.
It has headings and then it has all the data.Even though headings are not actually the column headings, I need to convert these headings into actual headings when I get this data into the power query.But right now I'm going to select this table from here.And you can also have the web view here.This is a small tab.You can just click on it and have the web view of the web page.And I'll go back to the table view.Click on the table one and click on transform data.Here I have my table and this table need a bit of transformations and we're going to do that transformation as well.So first of all what I'll do I'll go to this left top corner and click on this small drop down here and I'm going to use this option called use first row as headers.
And now my headings are there.The next thing is to remove this bracket where it says you know 2024 estimate I don't need this this particular value.So I'm going to say copy this select this entire column and then go to transform replace values value to find and replace with nothing.Click okay and the value is gone now.And the same thing with this 2020.Select the column go to transform replace values.paste this and then click okay and the the bracket with 2020 is gone now but next thing is to convert these values into actual numbers so I'll select both the columns and then I'm going to go to thisdata type drop-down and convert it into whole number and now data type is changed the final thing is to split this column into two different columns so I have the serial number here and I also have the state
name I want two different columns one is for serial numbers and one is for statement.So I'll select this column and then I'm going to right click and say split column by delimiter.And this dot is already there.So I'm going to say okay.And now I have two different columns.So I'll say rank and then US
state.And my table is ready to load into my Excel workbook.So I'm going to go to home choose and load.And here I have my table cleaned and connected to that particular web page.Now let's move to our second table that we have on this web page finance.yahoo.com.So I'm going to take this URL from here and then again I'm going to go to my Excel workbook get data from other sources from web page and paste this here.And again it will take a few seconds to show me the navigator dialog box.And once I get all the tables, the list of all the tables, I'm going to click on the table that I want, which might be the first the table that we have on the web page cuz that's themajor table that we have.Here we have the list of all the tables which are there on the web page.
Let me just check one by one.Yes, we have all the tables.So now we want the first table that was the biggest table on the web page.And instead of going with the suggested tables, I'll go with this HTML table list where I have only one table because you see the headings are there in this table.And this table is way more well structured than the table is here that is you know suggested table table two.So I'm going to go with the table one.Click transform data.And I have my power query editor.And the table is there in the in the in the power query editor.Now without doing any transformation here I'm going to show you how you can get this Power Query refresh after X number of minutes.So I'll just load this data back to my workbook.And here I have this table into my workbook.
Let me just go to the query tab here.And from there I'm going to click on properties.So I'm going to check mark it.And then I'm going to specify how many after how many minutes I want this query to refresh to get the you know the latest data from that web page.So I'll say let's say 30 minutes.I'm going to say 30 minutes and click okay.And now this query will refresh itself after every 30 minutes to fetch the data the latest data from that web page from that particular table and get it into my you know Excel workbook using power quer.Now let's move to a third example which is quite simple example but super useful when you get data from web sources.So I'm going to copy this URL from here and I'm going to go to my Excel workbook and from there again data get data from other sources from web and I'm going to paste this URL here and click
okay.This time instead of you know having tables I get the sheet name because the that URL has a workbook and that workbook has this worksheet and that worksheet has this table.So that's the complete Excel structure that we have the object structure.So let me just click on the sheet one, click on transform data and I have this data into my power query editor and let me just click on home and click close and load and get the data intomy Excel worksheet.Now if you change that workbook on that particular URL and refresh the power query, power query will fetch that data from that workbook into your Excel workbook.

6. Folder File Lists & Combining Worksheets

Explains how to get a list of all files from a folder and subfolders with filtering by extension, then combines data from four worksheets in the same workbook using a blank query and a table-name keyword trick to avoid duplicate rows.

In the first example, we have a folder which is saved on my desktop.And in this folder, I have a few files here.Let's say four files.And then I have five folders.And each folder contains three files for the for each region.Now the idea here is to get the list of all the files from this particular folder, the main folder and all the subfolders.Let me just open my Excel workbook and then I'm going to go to my data tab and click on get data.And from there I'm going to say from file and then from folder.And now when I select this folder region data that is saved on my desktop and click open instantly it shows me this list of all the files from all the folders main folder and the subfolders into this dialogbox.Here I have a lot of details about all the files.
Let's say date modified date created and then the folder path the name of the file and extension of the file and few more columns.We will understand about all these columns in just a few seconds.But let me just take this this particular data table into my power query editor.You can see here I have these three buttons here.But instead of using combine or load, I'm going to go with transform data.And when I do that, it instantly get this table into my power query editor.Now here you can see all the details as I said about all the files from that particular folder.The first column here that says content is basically where the data we have for each of these files.You can see here we have this entry that says binary and when I click on this click on this cell you can see I get this file here that's the file from the from the folder and in the
same way when I click on this particular binary I get this file that is southeast sales 2025 from the subfolder of the main folder whenever you see a column with these entries binary that means this is linked toa workbook or a file where you have data or you want to get data from.Bindary is always a data from a particular file that you have connected.And after that we have the name of the files that we have here.We have CSV files, we have text files and we have Excel workbooks and then the extension of the of all the files from the folder main folder and subfolders and then the date of modified created and then wehave this record column here and then in the end we have this folder path.Now what I want here I want to have the name of the files and then I want to have the folder path.
But let's say if I just want to have the name of all the Excel files instead of you know text and CSVs I can do one thing here.In the extension column I have this filter and I'm going to click on it and from here I'm going to say text filters and then go with contains.Here I'm going to type the extension of Excel workbooks that I want to include in my filter.So if I want to go with let's say XL SX that means only a single format that is for the Excel workbook.But if I want to go with let's say all the macro files which is the format XL SM and XL SP that means the binary format of the Excel workbook.If I only use Excel Excel will include all those formats as well all those extensions.So I'll click okay.
And now here because I only have XLSX that's why I have filtered out these files.But if you just want to have you know Excel SX because we already have you know that that file the extension in our column in that case you don't need to write this particular condition you can simply openyour filter and untick all the other files and click okay and you will get the Excel SX format filtered out here.Now the next thing is select the name column and the folder path column and then right click and say remove other columns.And now I have the name and the folder path.And what I'll do, I'll simply say close and load.And it will load this table, a simple table with file names and folder path into my Excel work.Now what I'll do, I'll go back and here I'm going to create one more or few more files.
So I'll just copy paste these files here.And I'm going to say five just to name it.And then six and then seven.All these files are blank files.I just want to show you how to get the name of the files and it has nothing to do with if a file is empty or not.It will still get the name for you.So let me just go back to the table I have here and now let me just refresh my query here and you can see I get all the other file the name of all the other files here inmy table.Now let's start with the data that we have.So in this workbook I have four different worksheets and each worksheet contains data for a particular city.Now the idea is to combine this data into a single worksheet.So that worksheet will be in the same workbook.
So what I'll do I'll start with doing the first step and that first step is to convert entire data into into an Excel table.So I'll go to each worksheet one by one and convert that data into an Excel table.So first of all I'll use Ctrl A and then Ctrl T and click okay.
Now my data from all the worksheets is an Excel table.But there is one thing that I need to do before I get this data into the power query editor and that is to change the name of the tables.And for this I'm going to use a specific format.I'll use the name of the city that I have.Let's say I have London and then I have New York, I have Mumbai and then I have Sydney.So I'm going to use names for the name of the table but I'm going to also use a keyword along with that name.I'll go to table design, click on table name input bar and I'm going to say London and along with that I'm going to say underscore PBX.So this is the one keyword that I'm going to use and this keyword adding this keyword into the name is very very important.
I'm going to show you why we are doing this later in this chapter.So first of all I'll say this is the name of the table and I'm going to do same for all the three worksheets with all the three tables.
So my data is ready.All the four worksheets have tables with the name and the keyword that I have mentioned that is underscore table.You can use any keyword for the names but I'm using this standard keyword that is underscore tbl.TBL means table.Now the next step is to go to the data tab and go to my favorite options that is get data and from here I'm going to say from other sources and then click on blank query.I'm not connecting any table right now.I'm just opening the blank query.it will instantly open the power query editor as a blank query.I don't have anything in the power query editor right now.First of all, I'm going to sayso that's the name of the query that I have right now.And to get the data from all the four worksheets I'm going to say this particular function and without specifying anything within the function I'm going to hit enter.
And here I have the small table where I have name of the all the tables from the four worksheets.And here is a table which is the one column but every single entry here in this column that is content I have a table inside.You can see here in this particular icon here which is not like a filter icon.It says two arrows which are expanding horizontally.And when I click on it, it shows me all the columns from the data.And I'm going to say okay.And my data is here.the data from all the four worksheets into power query combined in a single table.But there's one most important point that we need to know here before we start using this data, you know, before we load this data into the power creator.But before that, I'm going to show you something.Let me just close and load this data for you.
You see, I have 481 rows loaded from these four, you know, worksheets.Let me just move it to the first.So these are the four worksheets from where I'm getting data and I have total 481 rows loaded.Now when I refresh, let's say if I add you know a few more lines in any of these you know these worksheets and refresh there's one big problem that is going to happen.Let me just click on the refresh.Now instead of 481 or the rows I have added to the to the to the data the source data I have 961 rows.And why is that?Because when I go to power query and specify the entire workbook, hey, I want to get data from this particular workbook that is the current workbook and I get data from the four worksheets.But as soon as I load a new worksheet with the merged data, that worksheet also becomes the part of current workbook and every time if I load or refresh this data, it will keep on adding those merged rows.
So if you have 400 rows it will become 800 and then you refresh those 800 will become 1200 and this loop will keep on adding those 400 rows every time you refresh your table.To solve this problem we going to do a simple tweak here.Let me just go back and click on edit or you can also go to the query tab and click on edit from here to edit your query in the power query editor.And now the real work of that keyword that we used in the table named tbl is going to help us here.So I'll go to this name column that I have at the end and I'm going to say filter it for me.Click on load more.So it'll show me all the tables.And here I'm going to apply a small filtering trick.So I'll go to text filters.
go to contains and here I'm going to say underscore tbl and click okay.This way when you add a new worksheet let's say you add data for New Delhi or you add data for let's say like for for Washington DC you need to use that keyword tbl with the name of thetable so that power query will identify that I need to filter data only for that particular keyword it will not consider the current workbook where you have the main data to get into the power query.So it will always filter that data for you.I'll just go and close my data here.And now I have the correct count of rows from all these four worksheets from all the four tables here.

7. Combining Workbooks from a Folder

Combines data from multiple workbooks in a folder, first when sheet names are identical using the combine button, then when sheet names differ using a custom column with the Excel.Workbook function and header cleanup.

This time we're going to get data from multiple files from a single folder into our current work.If I show you, I have this folder on my desktop where I have four different files for four different months and each of these files have data for one single month.A single month and here we have two conditions.The first is the structure of the data is same in all the all the workbooks and the name of the worksheet where data is stored is exactly same in all the four worksheets.That's two conditions we have here.Let me just close this file here.And now let's start merging or combining data from all these four workbooks that I have in a single folder.I'll go to data tab, click on get data and from file and then I'm going to say from folder and here is my folder where I have you know all the all the workbooks and I'm going to say
open it and within a few seconds it gives me this list of list of files that I have in that folder.This is not the data but just the list of the files and here below I have three buttons to use.One is combine, load and transform data.I'm going to ignore load button and transform data.I'm going to go with the combine.And when I click on this button further I have three options that says combine and transform data, combine and load and combine and load two.I'm going to go with combine and transform data.And again within a few seconds it shows me this combine files dialog box where I can preview the data that I have in all the four workbooks.And again as we have learned we have two ways to you know connect data from a external workbook.one is by table and one is by the worksheet that we have in that particular workbook.
And here in this sample file dropdown, I can preview data from all the four workbooks one by one.I can select one workbook from here and then go by the table or go by the name of the worksheet.I'll go to first file again and this time instead of going by the name of the table, I'm going to go with the name of the worksheet.I'll select sales and click okay.You can see here the data from all the four workbooks is now into my power query editor.If I just open this filter from here, you can see I have data from all the four files.Let me just add a few transformations here.The first thing I'm going to do is right click on it and delete this column that I don't want.Here I'm going to say remove.And here I have my applied step.
And then I'm going to filter out all the entries where delivery is not done.I'm going to say remove no and click okay.And I'm also going to filter out where the product or the invoice is returned.I'm going to say no this time and click okay.This is my actual sales data where I don't have any return.I don't have any delivery pending.The next thing I'm going to do is I'm going to again right click and say duplicate column and for invoice date that's the duplicate column here.I'm going to say month name and right click and then I'm going to say transform month name of the month and here I have the name of the month.And now let me just take this column from here, drag and drop it after the invoice date column.And here I have month, the invoice month.
The next transformation I want to have is to filter out quantities where the quantity is above five.I'll use the filter again.I'll click on the filter and I'm going to say number filter and greater thanfive and click okay.Now here's my filtered rows step here and my transformation is almost ready.Let me just go to close and load and click here.And here I have my data from all the four workbooks including all the transformation I have performed in my data.Now in this example we have same four different worksheets but we have now a different scenario and that scenario is in each of these worksheets we have a different worksheet name.So if you look at here I have January here and then I have February and I have March and then I have April.That means the name of the worksheet is different in every workbook.
And now we're going to get data from all these Excel files into a single Excel file using Power Query.Let me just close all the workbooks and let me just open my Excel workbook.Blank Excel workbook.And here I'm going to go to data tab.Click on get data from file and from folder.This is the folder that I'm going to connect.So I'm going to select the folder.Click open.And here is the dialog box where I have the list of all the all the files from that particular folder.Now here I have again this combine button and then load and transform data.If I click on combine, let's say let me just go to combine and transform data and I get this preview dialog boxyou can see even if I just select different you know workbook try to select all the all the workbooks that I have in the folder you can see the name of the worksheet is different in each of these
workbooks that's the reason I cannot go with this option I need to use a different place so let me just cancel it again go to get data go to from file and from folder again connect the folder clickopen and now instead of going to combine button I'm going to click on transform data it will not get the data instantly from the workbooks this will give me the small table where I have a list of allthe workbooks from the folder here is the data that is simply a list of all the workbooks from the folder and in the first column that is content this is the column where I have data from all thosefour workbooks from the folder.So what I'll do, I'll select the first column and then I'm going to select the second column and I'm going to say right click and remove the columns.
Now to get data from this column to get all the tables, I need to add a custom column here.We're going to learn about custom columns in detail in this master class.But right now I'm going to go to add column and click on custom column.So custom column is basically a column where you add a formula and then get some values using that formula.So here I'm going to say data that's the name of the column and here I'm going to use a function a formula the power query formula it starts with excel dot workbook just remove it excel dot workbook andthen starting parenthesis and I'm going to double click on the content column and it will add it in the formula for me and then close the function and here I have the small message that says no syntax erroris here That means my formula is correct and there is no error in the syntax.
So I'm going to click okay.And here I have one more column here that says table for each of the entries.Now when I click on this table, you can see I get this small table here in in the preview section.But this table is not the table that I want to extract from the from the workbook from all the workbooks.It has the name of the worksheet and then it says the data is in table and then again name of the worksheet.few details I have here.So now what I'll do here I have this small icon which is not the filter icon.If you see it shows me two arrows pointing to different directions.This means I can extend this table in horizontal way.So when I just click on this it shows me a few columns here which are not the columns from the actual data.
But let me just click okay and show you.It shows me a few details about the worksheets like name again the table that I have in the worksheets and then again the name and kind of data like it's a worksheet so it says sheet here.Now it's time to get the data.So now my data is in this you know this particular column.We had this column here and then we extracted these entries from these particular cells and now we have this column that says data dodata and in each of these entries we have our table from the worksheet.So when I click on it, you can see here in the preview I have this table here.Now to get all the tables from all the all the worksheets of all the workbooks, I need to again extend this particular column.Again it shows me these two arrows here on the button.
That means I can further extend this column.So I'm going to click on this and say okay.And now I have my data from all the four workbooks.Now at this point I have my data from all the four workbooks into my power query editor.But I need to perform a bit of transformations here.You can see I have a few extra columns these three columns at the end of the end of the table and these three columns at the starting of the table.So what I'm going to do I'm going to simply use control key to select all these columns from here and also from here and I'm going to say right click and remove columns.Now here I'm left with only the columns that I have actually in in the data that I have in these four workbooks.But the last thing is to have the actual headings.
So you can see here this is the this is the heading row that I have and then again I have this heading row here and then one is here.So this way I have total four heading rows in my data because I have four tables from four different workbooks.So first of all what I'll do I'll go to this small corner and this drop-down and I'm going to say use first row as headers so that the first row that I have here for the first table thatwill be used as the heading row.So I'll say use first row as header and my headings for all the columns is now changed.But I still have three more headings here, three more heading rows.So I need to remove them.So I'll simply open a column and that's a date column.So I'm going to uncheck this invoice date value from here.
So it will remove it will filter out all the entries all the rows where I have this value invoice date.That means the rows where I have headings.So I'll say untick click okay and my data is now perfectly fine and it has the actual data from all the four workbooks.So I'm going to go to my home tab, click on close and load and it will give me data in my worksheet from all the four workbooks.

8. Importing Files by Path & from Web URLs

Shows how to combine files saved in different locations by listing file paths and using the File.Contents function, then imports files stored on the internet using Web.Contents with URL lists.

Let's think about a different situation.The situation is we have same four files where we have data but this time all these four files are saved in different locations.We're going to get data from these files but using completely different steps.You can see here I have listed the path of all the files.If you want to have a path for a file, you just need to open the folder where you have that file and then right click and then go to this small option that says copy as path.You need to right click and click on copy as path.And then you can list down all the paths here like this.And then let me just add a header and convert this list into an Excel table.I'm going to press Ctrl T and I'm going to say my table has headers.Click okay.
And my table is ready.Again, I'm going to go to my data tab.And from here, I have the small option that we have already used that says from table or range.I'm going to click on it.And it will instantly load my small table with all the file paths into the power query editor.Now here the next thing is to use a custom column.I'll go to add column and click on custom column.Here I'm going to add this name my data.And here I need to add a simple function that says file dot contentsstarting and this is the column where I have the path all the paths and I'm going to close the formula and it says no syntax error has been detected and I'm going to take okay and here I havethis one particular column.If you remember, we have seen the same column in the last example where we trying to get data from from workbooks where the sheet name was different.
The column is here.I'm going to click on it.It says expand downwards to extend this table in a in a vertical way.Now it's time to click on this expand button and I'll get this dialog box where I can select the sheet that I want to use to get data from all the four files.I'm going to click on it.Click okay and within a few seconds I will have the entire data from all the four files.Here we have data in our power query editor.And the first column obviously is the column of file path that we already have in our original table from the workbook.And after that for every file path we have this table that is from the sheet one from each of the files and every single entries here in our power query editor.And now it's time to do a bit of transformations to this data.
First of all I'm going to delete the first column where I have file path that I don't need.So I'm going to select the column right click and say remove.And after that what I'm going to do is I'm going to go to quantity and unit price.And here I want a new column with the total amount.I don't have the total amount here.So I'm going to get the product of quantity and unit price.What I'll do, I'll again go to custom column and I'm going to say amount and the formula is quite simple that says quantity into unit price and I'm going to say okay and it will instantly give me thisthis column here for amount at the very end of my table and as we have already learned I need to change the location of the column I'll take it from here and drop it after the unit price.
Instantly I have this step here that says reordered columns.And here is my column.Now the next thing is to change the format of this column.Not only the amount column but unit price as well.I'm going to select both the columns, go to home and from there I'm going to say data type currencyand my columns are now changed the data type of the columns and my data is now ready to load into my Excel work.I'll say close and load and here I have my data from all the four piles.Now here's the best thing.If you want to have let's say you have one more Excel file that you want to include in this list you just need to go here and paste that that path here and just go to the table refreshit and we get the data from that file also.
And if you want to delete something you just need to select that row and right click and say delete and when you refresh again the table it will remove data from that particular file path.This is one of my favorite ways to use Power Query to get data into Excel.We have four different files and mind you this time these files are not saved on my own system.These files are on somewhere on the internet.This is my own blog excelchamps.com as you know and these files are stored on the website and now I want to get data from these four files.Now this is one of the interesting things as I said to do in Power Query.We'll do bit of same steps as we have learned in the last you know last section where we got data from four different files from the from my own system but we're going to use a different function here
to get the data.What I'll do first?I'll select this, say Ctrl T, and convert it into an Excel table.And for the table, this time I'm going to change the name.I'll say URL S URLs.Again, I'll go to data tab, click on table or range, and within a few seconds, I will get this data, this table into my Power Query editor.Here's my Power Query editor and here's my table with four URLs as file address.What I'll do next, I'll go to again add column and click on custom column.And this time I'm going to say my data and here I'm going to use a function power query function but a different one.This function goes by web dot content and then URLs is the column that I have here.If you are typing it, you can simply click on the name of the column and it will add it for you.
I'll close the function.It says no syntax errors has been detected.So I'm good to go.I'm going to say okay.Our data column is ready.If I click on the first entry, you can see I have this Excel file that says Excelchams.com and same for this file.Same for this file and same for this file.I'm going to click on this icon again that says to expand this column.I'll say okay.Click on it.I'm going to click on the sheet one.Click okay.Here is my data from four files, four different files from the internet.And again, I have the first column here, which is the path for each of these files.And then I have this data.This data is not that big.I have just a few columns, five columns.But I was able to get this data from web using power query.
And again, I'll do bit of transformation here.I'm going to right click on the URL column, click on remove to remove it.And after that I'm going to add one more column here.And that is getting the price for this data.I know the units sold and then I know the revenue and I want the average of each of these entries.That's the price.I'll go to add column.Click on custom column and this time I'm going to say average price and then revenue and units sold.Click okay.And here I have my column average price.Now there's one more thing that we need to understand here.You can see we have a few steps automatically added by power query into the applied steps section and some of these steps are changeable.You can edit these steps and make a few changes.If I go to removed other columns and here I have this small settings icon.
When I click on it, it shows me this dialog box where I can choose the columns that I want to keep and columns I want to remove.My data was the column, the initial column that I have added using the function and power query has removed that column and even I can also remove the URL column that I have deleted myself and if I justyou know uncheck it, I can remove it from here.If I do it now, I'll get error here because if this URL column is not here after this step, Power Query will not be able to remove it here.And that's why I'll get an error.So, I'm going to click okay, leave it as it is, and come back to my final step here.After all the transformations, my data is ready to load into my Excel workbook.I'm going to click on close and load.
And here is my data from all the four files from web into my local Excel workbook.

9. Combining CSV, Text & Google Drive Files

Combines CSV and text files from a folder while filtering by file format and choosing the right delimiter, then demonstrates importing an Excel file from Google Drive by building a modified share link with the file ID.

Now let's talk about a different example.Here we have data for four different regions.But the problem is in our folder we have three different types of files.We have CSV, we have text and then we have Excel the Excel SX file format.You can see here the first three files are from the same region and then the next three files are from the same region and then again the next three files and then the next three files.So I have midwest, I have northeast and I have southeast and then I have west.Now the problem is the data in these three different formats is same.And if I try to combine data from all the files, I'll get data three times for a single region.Now the whole idea here is to get data but only one time not three times.So what I'll do, I'll go to my blank workbook.
I'll go to data tab.Go to get data from file and then from folder.So I'm going to select the folder where I have the data, the region data and click open.Now again I get this list of all the details for all the files that I have in the folder.So I'm going to click on transform data and after that I'll add one more step here and that step is to filter out the files which I don't want.So for this I'm going to use the extension column.You can see here I have CSV here, I have text and then I have Excel SX that means the Excel workbook.So I'll open this filter here and I'm going to say I don't want Excel workbook and I don't want text.Click okay.And now I only have the CSV file format.So what I'll do I'll select the content column and then the name column.
And then I'm going to say right click remove other columns.Now as every single entry here where I have binary this entry means this single entry means the entire data from this particular file.So now I'm going to click on this expand button and it shows me this dialog box where I can choose how I want data from our CSV files.Now what happens here when we choose Excel files to get data to combine data from multiple files.We have a standard format in Excel but in CSV we have a different standard format where data is combined into a single column using a delimiter and that's why this particular dialog box is different from the dialog boxthat we got in our while combining data from Excel file.So we have this option this particular option here that allows us to choose what kind of delimiter we want to use to get data from the CSV files.
So I can choose let's say if I want to go with a different del limiter.Let's say I want to go with equal sign semicolon space tab or even the custom delimiter or I can also use a fixed width option here.So I'm going to go with the comma and I'm going to say okay.And again within a few seconds I get the entire data from all the four CSV files.But now there is one mistake that I have made and I want to correct that mistake.So if I go to removed other columns, this is a step that power query added automatically while combining data from all the four CSV files.I have this small settings icon here and I'm going to click on it.It shows me the columns that has been removed while getting data from the files.But I want this name, this particular name column back and that's why I'm going to check mark it.
Click okay and I'm going to come back to the present step that is changed type.And now apart from having the data the entire data from all the four CSV files I also have this particular column the name column here where I can see the name of the file.So it says Midwest sales 2025 dot CSV.So this is also a kind of a testing or a proof that I get data from the CSV file not from the Excel or text file.So that's why I have this column here.Now let me just click on close and load and get this data into my new Excel worksheet.So let me just out of it.Now let's do a kind of verification here if our query the entire steps of the query is working fine or not.You can see here this is the folder where I have data for four regions and in three different files.
What I'm going to do is I'm going to add three more files here for a separate reason a different region.Let me just add these files here.Let me just drop it here.You can see now I have data for five regions.After west I have central sales.That means the region central.Now if I go back to my Excel workbook and show you the regions.I have four regions here.Midwest, northeast, southeast and west.I don't have the central region.So what I'll do?I'll simply right click and say refresh.And within a seconds after refreshing now I have data for central, midwest, northeast, southeast and west.I have data for five regions.But the best part is I only have data from the CSV file.When I open filter from this column, you can see I have this file central sales 2025.CSV.
That means it is filtering the file and then giving me data based on the format and that is the CSV extension of the file CSV.So we are not only combining data from multiple files, we are filtering out what kind of files we want to use to combine our data.Now let's say we want to get data from text files instead of CSV files.In that case, you need to follow the same step.But I'll show you there is one simple difference between getting data from CSV files and text files.So what I'll do, I'll let this query as it is.I'll just leave it here.And I'm going to go to data tab again.Click on get data and then from file and I'm going to say from folder.I can also copy the query but for you just to show you I'm going to create a new query here by using all the steps from scratch.
So I'm going to select the region data that's the folder.Click open and here I have my the list of all the files.I'm going to click on transform data and here I have the entire list of files here in my power query.So I'm going to say filter out text files.Click okay.And again I have all the files which are text files from the folder.And now I'm going to select the content column, name column and I'm going to say remove other columns.And after that I'm going to expand it from here.And it shows me this combine files dialog box here.Now here is the real difference between CSV and the text files.In the CSV files, we had a comma as a delimiter to split the entire data into multiple columns and then combine it into a single Excel workbook.But this time with text files, we have a tab to use as a delimiter.
And that's the biggest reason I perform all the steps again to show you how it works.But no step is different here.The only difference is the delimiter.So I'm going to go with the tab.Click okay.And here I have my data into the power query editor.And again I'm going to go back to my removed other columns.Click on here.Get this name column here.Click okay.Come back to the latest step.Click on close and load.And here I have my data from all the text files, filtered text files into my Excel worksheet.This example is going to help you in a big way.I have an Excel file on Google Drive and I want to get data from this file.Now steps are quite simple but we need to create a link to use in the Power Query.So this is the file that I have on my Google Drive.
So what I'll do either I'll open this file and I'm going to say open with Google Sheets and then I'm going to go to the share button here and I'm going to say copy link or you can justsimply click on the share and manage the entire access here.So you need to have this anyone with the link in the in the access and say editor.It will allow you to copy lick from here or you can simply go to the folder where you have the file and right click and say share and say share.It will show you the same dialog box again anyone with the link and editor.So I'll copy the link from here and then I'm going to go to my notepad.Here I have this format of the link.First of all I'll paste this link that I have got from the Google drive for that particular file.
And in this link I have a ID that I need to copy it from here.So let me just show you where you have this ID.So in this entire link you'll see this forward slash and D and then you'll see this forward slash and edit.And your ID is in between these two words.This D and forward slash and forward slash and edit.So I'll copy this ID from here.And I'm going to add this ID here after the format the link of the Google Drive that I have.And now I'm going to copy this link from here.And I'm going to go to my blank Excel workbook and then go to data tab.Click on get data from other sources from web.I'll simply paste my URL here and I'm going to click okay.And then within a few seconds I get this icon of file here in my power query editor.
Here I need to follow a few different steps.So I'll just right click on here and say Excel workbook.Now here we have the same situation when we connect a file with power query and that file has a table.Power query shows us data in two different ways.The one is using the worksheet name and one is using the table name.And the same thing is happening here.So I need to go with one thing here.one is the you know the actual worksheet name or one is the table.You can see here in the kind column I have this sheet and table.That means this data is coming from the sheet and this data is coming from the table but the data is same.So I'll simply open this filter here and I'm going to say I want to go with the table.Now in this column where I have the heading data I have this entry that says table and when I click on this I have my table from that particular workbook from Google Drive.
So, I'll click on this expand button and click okay.And here I have my data from Google Drive.The only thing that I need to do, I need to remove a few columns.The first column and the last three columns.And now I'm going to say remove columns.And my data is ready to load into the power query editor.But before that, there are a few things that I need to change.And that is the format of the date column.So I'll go to the home tab, click on date.And I also need to remove this data dot into the keyword that is before every name of the header.So I'll do it one by one.Now my data is ready to load into the new worksheet.So I'll go to home tab, click on close and load.And here I have my data all the way from a file from Google Drive.

10. Splitting & Merging Columns

Covers splitting columns by delimiter, by character position, by line break, and into rows, then shows two ways to merge columns: the merge columns option and a custom column formula that keeps original columns intact.

Now let's learn how to split data using power query.Here I have this data and I'm going to load this data into the power query editor.I go to data tab and click on from table and range and it will load my data into the power query editor.Now let's say if I want to split the full name column using the space in between in that case this space will be the d limiter.When I click on this column and select this column and right click I get this option here that says split column and then further I have few options to split my column and the same option is there onthe home tab and here is the split column drop-down and all the options are there.Now again I'm going to right click and go to split column and say by delimiter.Now here Power Query is smart enough to identify which character is the delimiter in this column.
And I already have this option that is space here.And when I click okay, it split my column using the space.And here is the first name and here is the last name from the full name column.And now let me just rename these.Now in this column you can see here my delimiter is a hyphen.And when I right click and say split column go to delimiter.This time again power query is smart enough to identify which character is the delimiter.But this time instead of using any predefined character so if you open this dropdown you have a few predefined characters that you can use as a delimiter.Power query moves to the custom and here I have the hyphen which is already there.It entered that hyphen for me to use as a delimiter.That is something very very smart from Power Query.
But before we spill this column, we need to understand these three options that we have here.Let me just use a use a example here.Let's say if I use the first value that I have here that saysnow in this value you can see here I have one hyphen here and I have one hyphen here.Now when I use the first option that says leftmost delimiter, Power Query will use the first delimiter and split this part in one column and this part in one column.And if I choose the rightmost delimiter, that means the delimiter the first delimiter from the right side and Power Query will spit this part of the value in one column and this part of the value in the inthe second column.But when I use each occurrence of the delimiter that means what I'm saying here is to use this delimiter as well as this delimiter and in the end I will get three columns instead of two and if I
have more than two delimiters in that case I'll get that number of columns in return you can choose how you want to use the delimiter to split your column in multiple parts and I'm going to go with eachoccurrence of the delimiter and click okay and here I have three columns the first part the second part and the third part of the product code.And now in this example, we're going to use position of the character to split our column.You can see here I have this date here, but the format of the date is quite different.I have year first and then I have the month and then I have the day number of the month.Now if I just select this column and go to split column and go to by position, you can see here power query asks me for the position that I want to use to split the column.
But here as I have this example here, it allows me to have multiple positions to split the column into multiple columns.But I need to start with zero instead of the the further number.Let's say if I want to split, I want to make the split after the fourth character.Instead of just saying, hey, I want to make the split from the fourth.I need to start from the zero and then I need to move to the fourth.That tells power query, hey, start from the zero and make the first cut after the fourth character.And then after the fourth character make the second cut at the sixth character.And when I say this 0 4 6 and a comma in between when I click okay it gives me three columns.One is for the year that is 2025 and then one is for the month and one is for the the day number of the month.
But if I just go back just remove these steps.If I just go to split column say by positions.And if I just say split by four and six, which is kind of a confusion for anyone who is using this option first time when I say okay, this time I only get the month number and the daynumber.So that is why using zero is really really important.Let me just correct it from here.So I'm goingto say 0a 4a 6.Let me just click okay.And now I have year, I have month and I have the day number of the month.Now in the same way we have an advanced way of splitting our column.So if I just select this column where I have you know skills but these values the name of the skill is actually combined using a specific character and that character is a line break.
And when I just select this column, go to split column and then say by delimiter.This time you can see here I have this option in the drop down that says custom.And this is the code for the line break.And here I'm going to choose each occurrence of the delimiter because I want to split all the skills into multiple columns.And here power query is also specifying that what is the maximum limit of columns I have.So if you see here I have three skills in the first value but I have five skills in the fifth value here that means the maximum skills that I have in a cell is five and that the reasonthe maximum number of columns that I will get after the split should be five and that's why power query shows me the five here which is automatically not by specifying me and when I click okay now I have
five different columns with the skills the first skill second skill third fourth and fifth.Now let me show you a different way of splitting columns.Normally when you split columns you get the first column and then you get the second column and then you get the third column depending on the number of values that you have in the column that you want tosplit.But you can also split your column in a vertical way.So let me just select this column from here and then go to home tab click on split column and then go by delimiter.And here you can see I have this advanced options.And when I click on it, it shows me one more option further that says by columns or rows.And when I say rows and I'm going to say this time instead of space, I'm going to go with a comma and a space.
And you can see the data that I have here.I have three names in every single entry here.And I want to have all the three names from the first cell and then all the three names from the second cell and all the three names from the third cell.This way I want all the names in a single column.So when I click okay here I have this command space and here I'm saying each occurrence of the delimiter.And here I'm saying split into rows not into columns.And when I click okay I get all the names all the names in a single column.The only thing that I need to do here if you have some spaces here extra spaces you can just use the trim option.You just need to right click and say transform and then say trim and it will remove all the spaces if you have extra spaces otherwise there is no need to use this step.
Just close and load your data and it gives you all the names from this structure into a single column.Now let's understand how to merge columns in power query.You can see here I have this column with the first name and with the last name.My idea is to have a single column with the full name combining first name and the last name.Now for this we have two different ways in power query.So what I'll do I'll select the first column which is the first name and then I'm going to select the second column with the last name and I'm going to use control key.I'll press and hold the control key and select the second column that is last name.Now my columns are selected and now I'm going to say right click and go to merge columns.You can also go to the transform tab and here you will find this option called merge columns.
You click on it and it gives you the same dialog box.And this dialog box is pretty simple to use.First of all, you need to specify the separator here that is you can use space, you can use semicolon, equal sign, any separator that you want.But I'm combining first name and last name.So I would go with the space.And in the end, you also have this custom option.You can specify the separator that you want to have in between these two these two values.And now I'll go back and say space.And here in the second option which is a input box that allows me to specify the name of the new column.So I'm going to say full name.And now as soon as I click okay, it gives me a new column here with the combined first name and last name.
And the name of this new column is full name.Now this option is useful where you don't want to have the original original columns in your data.You just want the new merged column.But if you want to have the original columns as well as the new merged column, in that case we need to use a different way.Let me just remove this step from here and I'll go to the add column and click on custom column.Yes, we're going to add a custom column here.So I'm going to say name is full name and then I'm going to write a very simple formula here.I'm going to click I'm going to double click on the first name column and it gives me the first name column in my formula.And after that I'm going to say amp% and double quotation marks.And within the double quotation marks I'm going to use a space or you can use any separator if you want a different separator.
I'm going to say again an amp%.So here what I'm saying first name give me first name and then give me this space after the first name and then I'm going to double click on the last name.Now my formula is ready that says first name a space and then the last name.And now I'm going to click okay.And here I have this new column.New column where I have merged values from first name column and last name column.And name of this new column is full name.And I can also just move this here before the first name.Now I have full name, first name and last name.And my original columns as you can see are intact in my data.

11. Filtering & Sorting Data

Explains text, date, and number filters, handling null values, applying multiple filters, and clearing them, then covers single and multi-column sorting plus the reverse rows option.

All right.So now it's time to understand how to filter data in Power Query.And this option to filter data is exactly same like we have in Excel.And that is why it is equally powerful.Now if I just show you the data I have here which is order data and I have multiple columns here.And if I just filter the first column that's the order ID.You can see I have the exact same filter option here.So if I just want to filter a specific order or multiple orders, I just need to unselect all first and then I can select that order that single order or multiple orders and just click okay and it willfilter those orders for me the entries for those particular order ids.Now if I just go back delete this step here and again open the filter here and if I want to unselect or if I want to filter out a few order ids I can just unselect them from here.
And when I click okay, it gives me data after filter outing those particular order ids.So this is a simple way of using filter here.You can just open the filter option here and then select or deselect any entry that you don't want to see in your data or you want to have those particular entries.Now if I just go to the order date here because this is a specific column where we have dates as values and when I click on this filter again I get the same same values here to filter.But when I go to date and time filters I have a specific list of options that I can use to filter out my dates.So you can just check out all these options one by one.Let's say if I want to filter based on years say next year, this year or last year.
These are some of the predefined ways to filter dates based on different ways.So you have a specific list of options to filter different kind of data.So if I just go to data where I have values, let's say if I go with the amount or unit price column and when I click on it, it gives me number filters.That means the value in this column is numbers.And that's why I have these specific options here.If I want to filter data greater than a value or greater than or equals to a particular value or less than or less than or equals to.So I have all these customized ways to filter my data just like we have in Excel to filter a data.All right.This is one more thing we have in Power Query that is exactly same like Excel.So let's say if I just select the west value from here from the region column and I want to filter out all the entries where I have region west.
So instead of going to filter option what I'm going to do?I'm going to right click here and say text filter and then say equals and it will filter out all the entries with region west for me.As I said it's exactly like we have filter option in Excel.Now let me show you an example here that is going to help you a lot in power query while dealing with data while transforming your data.If I just go to this order status column here and open my filter you can see I have multiple order statuses here but there's one more status that is null.That means there is no value in those cells here.And I want to filter out this null value.So I'm going to unselect it and click okay.And now I have order status column.All the entries based on order status column where I have a status not where I have blank cells.
So you're going to deal with these kind of values a lot in power query.And filter option is quite handy in these situations.And just like any other transformation you do in Power Query, whenever you apply a filter in Power Query, you get this filter row step at the at the right side of your window where you have applied steps.Now the question is can we do multiple filters in Power Query?Yes, we can apply multiple filters to multiple columns in Power Query.So right now I have one filter here that says order status.I'm just removing all the null entries using the filter.And if I just go to the payment method column here, which is just one column before this order status, and open the filter here and say I'm going to go with only the credit card and click okay.And when I say this, now I have entries where I don't have the null values and I only have the credit card payment method.
But if you see the step here for these two filters, which are basically two different filters, I have a single step here.So that's how power query merge your steps.When you filter in a sequence for one column, two columns or even three columns, it will give you a single step here.If you want to remove a filter from a column or from multiple columns, you just need to do the exact same steps that we use in Excel.So if I just want to remove this filter, I can just go click on the filter button and say clear filter.And if you want to remove all the filters from your from your data, you can just simply remove this step from here which will remove all the steps that we have merged the filter steps we have merged inthis particular step.So if I just click on delete it will unfilter or it will remove all the filters from the data.
So these are the two ways that you can use to clear the filters.But you have this specific option that I said that is clear filters.Make sure to download the sample file and try out some of the filters we have learned in this particular chapter.Let's understand how to sort data in Power Query.And this is one of the most important transformations that you're going to do while working with data in Power Query.So if you look at here, I have ordered data where I have multiple columns.And now from this data, I want to sort this data based on region and category.So let's start with the region column.So if I select the region column and then go to the home tab, you can see here I have these two buttons here in the group that is called sort.I have two buttons.
The first button is to sort the data in ascending order and the second is to sort the data in descending order.And if I'm selecting a column where I have numbers in that case it will be like highest to lowest and then lowest to highest.So once I select this column and click on A to Z that means ascending.It sorts my column the entire data based on this column where I have Midwest the top and then I have northeast then I have southeast and then I have west.So these are the four regions I have sorted this data based on the region column.Now here you can see I have this filter button here but this filter button now is different from all the filter buttons that I have in other column.The reason is that this column is now used to sort this data and that's why the button is different.
It has a one arrow that goes upwards.That means this data is sorted in ascending order based on this column and I just use Z to A.Now you can see I do have the filter button.Now the arrow is pointing towards downward.That means this data is now sorted from Z to A.So this is the simple way of sorting a data based on a single column.And the same thing you can do from the filter option itself.So when you open the filter option, you can see you have both the sorting ascending and descending options here.And here the descending option is highlighted because this column is already used to sort the data based on descending order Z to A.Now what if I want to use two columns?I want to have a multi- column sorting.Unlike Excel, we don't have a multilevel or sorting order dialog box in Power Query.
We need to do it manually for the first column and then the second column.So my first column is already sorted.Let me just sort it again from A to Z.So I'll click on A to Z.And now data is sorted on A to Z.Now let's say if I want to include category the second level of sorting I want to use category column.I'm going to select this and I'm going to say A to Z again.Now you can see the region column is intact.I have Midwest first, Northeast, Southeast and West.And within the Midwest, the first region my category all the entries are now sorted based on the categories.So I have electronics, I have furniture and then I have softwares and I have supplies.So that's how my multi-level sorting is working here.Now what happens is when you do multi-level sorting, you sort two different columns one after another power query will list it as a single step here because you are sorting this data with two columns but in a sequence
and that's how it calls the multicolumn sorting.Now there's one more option in power query that you can use to sort your data.But this option is quite different from sorting your data with a you know traditional method.When you go to the transform tab, you can see you have this option that says reverse rows.Now this option allows you to completely flip your data using the last row as the first row and the first row as the last row.So it will completely flip your data.So you can just remove this step from here and go back to the original data with this sorting order and use this reverse rows option here.You can see here the first ID I have here 801 and the last is 80050.And when I use this reverse rows it completely flipped my data.Now I have the first ID as 80050 and the last is 801.
That's like completely flipping your data.

12. Replacing Values & Text Transformations

Demonstrates replacing values including match entire cell content and special characters like line feeds, then covers text cleansing with trim, capitalization, uppercase conversion, and extracting text after a delimiter.

It's time to understand how to replace values in Power Query.And if you look at my data here, I have few columns here.And most of these columns require some sort of replacement in value.So I'll start with the region column.And here you can see I have name of the regions.But some of these regions are not actually the name of the region but just a single letter.So what I'm going to do is I'm going to replace these with the actual names.Now to use replace values option in Excel, you have two different ways.One is you select the column and then you right click and here you have this option that says replace values.The second option is you go to the home tab and here in the transform group you have this option that says replace values.So these are the two ways to access the replace values option and it also depends on the type of the data that you have in a column.
So let me show you something.If I select this column where I have text values and right click and go to replace values, I get this dialog box where I can enter the value to find that I want to you know the value thatI want to replace and then the replace with.So that's the value that I want to replace with.But along with that I also have these advanced options here that I can use to replace values.But if I just select a column let's say let's say quantity and now if I just right click and say replace values here I only get these two input bars where I can you know enter the value tofind and replace value that I want to replace with but I don't have the advanced options here.So these things are based on the type of the data that you have in the column.
We'll start with the first column that we have here that is order ID and in the order id with this keyword o rd I have a hyphen and then I have numbers.So simple idea is to replace this this particular hyphen with a space.What I'll do I'll select the order ID column right click and say replace values and here I'm going to say value to find is the hyphen and replace with a space.I can also use any other character or value but now I'm going to go with the space.So when I click okay, it replace all the hyphens with a space.So that's the simple way of replacing your values in in Power Query.But now I'm going to show you an example that is very very important.Here in the region column, you see I have this letter N and I want to replace this letter N with the region name north.
Now if I just right click on this and say replace values and if I say I want to find the character or the letter N and I want to replace it with north.Now if I just click okay which seems like a right way.When I just click okay, it not only replaces the value n with north, it also replaces the n from other values where I have you know northeast with this word north.Now I need to use this option in a different way.So let me just click here and open my replace values dialog box.And when I say replace N with north, I need to go to the advanced option and I need to check mark match entire cell content.That means it will only replace N the the letter N from the cell where I only have the letter N.That means it is checking the entire cell content, not just the one part or one letter from the value or from the cell.
So when I say this and click okay this time I only get north for the cells.So the values where I have only n.So that's the other way of using replace values option when you're replacing values in power query.Now let me show you one more advanced way of using replace values.If you look at the customer name column I have names here but there is one thing that is unique here and that is the line break.If you look at the first name that's John after that I have a line break and the last name Smith is in the another line.I want to correct this and replace this line character with a space.So when I just right click and say replace values or you can just go to home tab and click on replace values from here.Now I'm going to click on advanced options and say replace using special characters.
It allows me to specify a special character.So I'm going to say line feed and this is the line feed.That's the code for the line feed that I have in my in my values in the customer name column and replace with a space.So this is a one space and I'm going to say okay.And now my customer name column has a space between first and last name instead of a line character, the line carriage character.Now it's time to understand how to transform your text using power query.Now if you look at my data here, I have these four specifically these four columns here.First name, last name, department and notes.Now these four columns are kind of that need sort of transformation or cleansing specifically these four columns.So we're going to use options in Power Query to do that.So if you go to your transform tab and then you go to this group that says text column, you have this specific drop down here that says format.
And within this dropdown we have further seven options.So right now I have five options available.But you can also use these two options as well.Now let's say if I want to remove all the spaces from these values all the spaces which are you know leading spaces and trailing spaces.I want to remove all these spaces.So what I'm going to do is I'm going to use this option called trim.And as soon as I click on this option you can see all the spaces which were in the beginning and the end of the values are now gone.That's the first kind of transformation that I required.And now what I'm going to do, I'm going to go to format drop down again.And I'm going to say capitalize each word.And when I do this, all the words, all the values, text values that I have, the words that I have get the first letter as a capital letter.
So my text values are pretty much clean here.But there's one more thing that I need to do.If you look at this department department column, I have this value here that says it that means the IT department and then I have this department name HR.In both these in both of these departments, the name the word or the the the value is is kind of something that I need to change.I want HR here but I want to have H capital and I want to have R capital as well.And same thing is with the it the capital the I in the capital and T also in the capital.Now here I have two options to do.First I can just select this department column again and then go to format and say convert to uppercase and it will convert all the values all the values that I have in this column into uppercase.
And if I don't want it that way I'm going to use one more option that we have just learned in the previous chapter and that is by replacing values.So I'll just undo this step.I'll select the department column and then I'm going to go to home tab and go to replace values.And here I'm going to say find it.Replace it with it but in the capital letters.But before I do that, before I hit the okay button, there is one thing that I need to need to check mark or I need to change in the settings.So I'll go to the advanced options here and I'm going to say match entire cell contents.So this is very very important if you're doing this kind of replacement.So I'll say check mark it.Click okay.and my the value it the department name it is now I capital and T capital and the same thing I'm going to do with the HR so I'll go again to replace values say H R and then and
match entire cell contents click okay and the value is now changed now let's do the last transformation that I want if I select this column where I have employee ID and within the EMP the keyword I have thishyphen And we have seen this in previous examples when we had the same sort of data.Now if I go to transform and go to this text column the text column group.I have one more option here that says extract.Now with the extract option I have further seven options that I can use to extract the data.So this is something when you want to split the columns you just want to extract data from a single column into you know.So this option is pretty useful when you want to transform your data but you don't want to write a custom formula for that.You can use any of these seven options.
So let's say if I want to you know extract text before a delimiter.Let's say text before a delimiter or text after a delimiter.In my case it's the ID that is 101 or all the ids that I have in employee ID.I want to extract them.So I'll say text after delimiter.And here I'm going to say the delimiter.Click okay.And here I have the employee ID with me after the hyphen from all the values.

13. Date/Time, Group By & Pivot Transformations

Transforms date and time columns using built-in options like date only and month name, summarizes data with basic and advanced group by, and converts data between tabular and columnar formats using unpivot and pivot.

When you're using Power Query to transform your data, you have a lot of options to deal with date and time specifically.You can see here I have this column here with the order date and time and then delivery date and time.Now if I select this column or both the columns and then if I go to my transform tab here I have these two specific drop-downs date and time and in these drop-downs I have specific options to use totransfer my data you know date and time.So if I go to date, you can see a lot of things I have here that I can do.Let me show you one of my favorite options first and that is date only.So you can see in this column I have date and I have time as well.But if I just want date from this this column particular column I want to transform this column into date only.
I can simply use this option from here instead of using any complex formula or even adding a new custom column.And in the same way if I go to time drop-down here I have this option that says time only.That means if I want to remove date from this column and from this column as well, I can use this this particular option and let me just go to date first.And here you can see a lot of options I have here to deal with dates.If I want to convert this date into year, I can do that.And for month, for quarter, for week and for day as well.And the same way in the time I have this option to get the hours, minute and second.Now let me just change this order date time into date only.Okay.So I'll go to date say date only and now I have only dates in this column.
And the same thing is for the the delivery date and time.And now let's say if I want to have the month name for the delivery date time.What I'll do I'll just right click and say duplicate column.So I have one more column here with with the same dates.And now I'm going to go to date drop-down and I'm going to go to month and say name of the month.We have used this option earlier in our last module to convert dates into the month name.If I just come back to my original date and time columns and this time if I select these two columns and go to time and say I want time only I have time instead of dates.And if I just go again and say I need the R, the value of R, it gives me the value of Rs here.
So that's how you can transform your data.If you have dates and times instead of writing comics formulas within Excel or even in Power Query, you can use these predefined options to transform your date and time data.Now it's time to understand how we can summarize our data using group by option.If you look at this data I have here, this is the order data and I have multiple columns here and total 150 entries.Now let's say if I want to know the region wise total sales, you can see this is the region column and then I have this column here that says total sales.Now I want to know what is the total sales for a particular region.I'm going to convert this data into a simple table to show region wise total sales.So I'll go to transform tab and here I have this option called group by.
And when I click on it, it gives me this dialog box.I'm going to go with the basic option.And from here, I'm going to select the column that I want to use for the for grouping this data.So I'll go with region.And here the name of the new column.I'll show you why I'm naming this new column here.Let me just say total sales.And then it asks me the operation that I want.So operation is basically the calculation or the way of summarization of the data.So when I click on this, it shows me a few options.I can do sum.I can do average, median, min, max, count, rows, count, distinct rows.That's like a unique entries.And I can also have all rows here.So I'll go with sum.And then further I need to select a column to perform this operation.
So I'll go with total sales.Click okay.And here I have this column that says west, southeast, northeast, midwest, which are the names of the region.And here I have this new column which is the summary of total sales for each of these reason.And that's why I gave this name total sales to this column in the in the dialog box.And now let me show you a different example of grouping uh data in power query.So let's say this time I want region wise total sales but I want to see it region wise category wise.So what I'll do again transform tab click on group by and here this time I'm going to go with the advanced one instead of basic and here I have the first column that is region and now I'm goingto click on add grouping and here category so now I have two columns to use for the grouping one is region one is category and now here I'm going to say total sales instead of count of rows again
I'm going to go with sum and here is total sales Click okay.And now this summary table shows me region wise, category wise, total sales.So that's how you can group your data.You can quickly group your data using the group by option in power query.This is one of the most amazing options that we have in power query.Now if you look at this data here that I have in my worksheet, this data is more like a pivoted data where I have region in one column salesperson and the headers are like the months for the year2025.And here in this tabular form I have sales for all the all the months for all the regions and salespersons.Now my idea is to reform or transform this data from this to this format where I have a complete column of region and complete column of salesperson and then I have a month column and then I have this
column for value where I have the total sales but all the sales all the values are in a single column.So let me just go to the data tab.Click on table and range and load this data into the power query editor.This is very simple.You don't need to do anything complex.You don't need to write any formula anything.You just need to select the columns.The first two columns.One is region and then the saleserson.And then you need to right click and say unpivot other columns.Unpivot other columns.And the moment you click on it, it will convert your data from the tabular form to this form.You can say like unpivoting of your data using power query.And I'll simply go to home tab, click on close and load and load this data back to my my new worksheet.Now it's time to convert this data that we have just unpivoted into a pivoted tabular form.
So I'll load this data into the power creator.Go to data tab.Click on table or range.And now what I'm going to do is I'm going to select this column, this particular column that I want to use in the headers.And now and I'm going to go to transform and click on pivot column option.So you can go to this any column group of options and then click on pivot column.This gives me this small dialogue box where I can choose the the column where I have the values.So I have values in the value column.So I'll say value.So this is the second step.The first step is to select the month column, the column that I want to have that I want to use for headers.And then click on the pivot column.And here in this dialog box, I have selected the column where I have the values.
If you have values in a different column, you can select that column.And after that you need to click okay.And here you can see now my data is converted into the into the tabular form where I have months at the top.So I have sales for each month in a different column.And I'm going to load this data back to my worksheet.And here you can see from this data we have got this data and from this data we have got this one.So it's completely vice versa of data.You can use both the ways whenever you're dealing with different kinds of data.

14. Data Types, Fill, Index & Custom Columns

Shows how to change column data types, fill blank cells down or up from adjacent values, add index columns with custom starting points and increments, and create custom and conditional columns using formulas and if statements.

When you load data into Power Query editor, Power Query is smart enough to identify the data type for each of the columns that you have in the data.Now if you look at the look at this data here with each column here at the very top of this column header at the left side, I have this small icon that shows me the type of data thatI have in this column.For date and time, I have this small icon which is a calendar and a small clock.That means this data is basically the date and time.And the same thing is with the delivery date and time.But when I move to the category column, you see here I have the small icon that says ABC.That means the data that I have in this column is the text data.So that's why power query identify the type of the data that you have in each of the column.
But if somehow you feels like or you you know just identify that hey this is not the right data type that power query has identified you can change the data type of that particular column.All you need to do is just go to the header of that particular column and then click on this small icon and it gives you this list from where you can change the type of the data.For date and time, if I want to have I want to have the date data type, not the date and time, I can just select it from here and it will convert it into a date.Now the date and time is converted into only date.And the same thing I can do with using the option from the transform tab.So once you go to the transform tab, you can see here you have the small drop down that says data type.
And when you click on it, it gives you the same list of all the data types that you have and you can change the data type from here.The fill down option is one of the most interesting options that we have in Power Query.If you look at my data here, I have this region column here and in the region column, I have these blank cells after the first entry of every region.And my idea here is to fill these these cells from the value above.So instead of doing it manually, I'm going to select my data, go to data tab, click on from table or range, and it will load my data into the power query.And instantly I can fill all these blank cells here.But let me show you something.You can see for all the cells which are blank I have null here.
That means power query has identified all the blank cells from this column.And I'm going to select this column.And then I'm going to go to transform.And here I have this small dropdown that says fill.And here I'm going to say fill down.That means take the value from above where the cell is non-blank.It will take the first value from here and use it up to the next non-blank cell from here to here and then from here to here and then from here to here and so on so forth.So I'm going to go to fill and say down and all the blank cells are now filled with the value from above.Now here in this data I have two columns where I have blank cells and I want to apply the multicolumn fill down.So I'm going to load this data into the power query editor.
And now instead of selecting a single cell, I'm going to select the first cell, category cell, and then the subcategory.And then I'll go to transform, click on fill, and say down.And it just fill all the values from me in a single click.In this example, I'm going to show you the second part of fill down option and that is the fill up.If you look at this column, I have again, you know, January here and then these four cells are blank and then I have February and these four cells are blank.And here I'm going to use the fill down.But here in the status column I have this value that says Q1 month one complete.And I want to have this value in these cells as well.So here I'm using fill down.But here I cannot use fill down because I want to add value from the cell downwards.
So the idea is to get this value from here and put it all the cells above.Here I'm going to use fill down and fill up.So let me just load this data into the power query and let's select the first column go to transform say fill down and here I have all the cells filled but here as I said we're going to usefill up so I'll again go to transform click on fill and this time I'm going to say fill up and instantly all the blank cells here are now filled with the value from downwards
Now in the first chapter of adding custom columns, we're going to learn how to add an index column.Now think about you have some data and you don't have anything unique in that data.Every entry needs to be unique, but you don't have any column that makes that data or every entry in that data unique.The easiest way to do that is to add a serial number column.that means the index column and in power query we have a straightaway option that you can use to add this index column.What I'll do, I'll go to add column.And here I have all the options that I can use to add custom columns.And here in this in this group of options, I have this dropdown that says index column.And when I click on it, it gives me three more options, three further options.One is to start from zero, to start my index entries or index column from zero.
Or if I want to start my index column from one, I have these two specific options.But if I want to start that index from let's say 10 or 11, I can use the custom option from here.If I just click on zero, you can see I have this index column here at the very end of the of the table that starts from zero.It's 0 1 2 3 and up to the last entry that I have into 39.And if I just delete this step from here and go back and say index column from one.This time my index column starts from the number one the the serial number one and it goes up to 40.That means I have total 40 entries.Now if I just delete it go back and click on custom I have this index column dialog box here that allows me to start my index column from a specific specific number.
If I want to start with let's say 11 and I can also specify the increment of if I want to have increment of two numbers I can specify here or if I want to have increment of let's sayfive numbers I can specify here let's say if I go with five and click okay you can see I have this index column where the the index the serial numbers are starting from 11 and then I have 16that means the increment of five numbers and this way again I have 21 and then 26 that's how my increment is this increment in the serial number or index column is happening in my data.These are the three different ways that you can use to add a custom index column.And mind you, whenever you add more data into it, this column will keep on extending the numbers as per the settings you have specified.
If you just starting your index column from zero, you'll get the you know next number in the data when you have more entries or if you have a custom index column like this, it will keep on adding usingthe same increment number.Now it's time to understand how to add custom columns in Power Query.And this is also your homework after completing this master class to try out more and more custom columns to to add with your data in Power Query.Once you go to the add column tab, you have this button here that says custom column.And when you click on it, it gives you this dialog box where you can write your own custom column using formulas in Power Query.The first thing is to add the name of the column.So let's say if I want to add two points in the performance score for all the employees I can write a simple formula of that that's just a addition formula.
So I'll say newperformance oops score and here I just need to write a simple formula that is adding two points in the performance score.So what I'll do, I'll double click on this performance score column because I have all the available columns from my data here at the right side of my dialog box.So I'll double click on it and it adds this column here in my formula formula section where I can write my formula.And after that I'm going to say plus that means addition and say two.Now my formula is ready.And you can also see I have this particular message here that says no syntax error has been detected.That means my formula is correct and I can go with adding this custom column using this formula.So when I click okay, I get this new column here that says new performance score where the score of every employee is now increased by two points.
Now let me just click here and show you one more thing that is your homework after watching this master class.So what when you click on this learn about power query formulas you get this link to all the formulas that are available in power query.So your homework is to learn more and more these formulas and try to add more custom columns in your data in Power Query.And now it's time to understand how to add a conditional column in Power Query using a if statement.Now what happens is in Excel, we need to write a function or a formula to write a if statement.But in Power Query, we have a specific option or specific dialog box that allows you to add a conditional column.What I'll do, I'll go to my add column here.And if I show you my data here, I have this this particular column here that says overtime hours.
Now in this I have asked for overtime for all the employees and some has some ask for overtime work and some has zero hours.My idea here is to have a column that says yes if there is any overtime and says no if there is no overtime.That means if there is zero say no and if there is any value above zero for overtime it should say yes.So I'm going to go to add column.Click on conditional column here and it gives me this dialog box where I can simply write my if statement.I'll start with the name of the column because I'm going to get a new column here.I need to have a name for the column.Say over time status.Now I'm going to select the column that I am going to use to test this condition that is overtime hours.
I'm going to say greater than and the value here to test is zero.If it's greater than zero, that means it should be a yes.And then I can also add a nested if one more condition to this particular if statement.But now I'm going to go with a simple yes or no.If this then yes.If not, then no.If the value in the overtime hours asks is greater than zero then I need a yes.Otherwise I need a no.And the moment I I click okay it gives me this column here where I have a yes and no based on the overtime status here.If overtime hours is 17 I have a yes and if it's zero I have a no.That's a simple way of adding a conditional column in Power Query.
Seek backward 5s ←
Longer seek (10s) Shift ←
Play Space Seek forward 5s →
Longer seek (10s) Shift →
0:00 Auto-scroll A Copy link at current time S

Power Query for Beginners - (Complete Masterclass + Practice Files)