How to Select All Columns in Power BI Query
Working with data in Power BI’s Query Editor often requires you to select, transform, or remove columns. While selecting one or two columns is easy, knowing how to select all of them at once is a simple but powerful skill. This skill can save you countless clicks, whether you're changing data types across a wide table or preparing your data for complex transformations. This article will walk you through a few different methods to select all columns in a query, from a simple keyboard shortcut to dynamic solutions using M code.
Why Would You Need to Select All Columns?
Before diving into the "how," it's helpful to understand the "why." Selecting all columns is often a preliminary step for a bulk action. It’s a common starting point for a variety of data transformation tasks in Power BI.
Here are a few common scenarios where this is necessary:
- Bulk Data Type Changes: Imagine you’ve imported a CSV file and Power Query has incorrectly inferred the data types. Selecting all columns allows you to change them all to "Text" in one go before you begin more precise cleaning.
- Applying a Universal Transformation: You might need to apply the same transformation - like trimming whitespace or replacing a certain value - to every single column.
- Bulk Column Removal or Reordering: A common pattern is to select all columns and then 'un-select' a few you want to remove using the "Remove Columns" command. It's often faster than selecting each column individually.
- Detecting Data Types: Power BI has a 'Detect Data Type' function on the Transform tab. You can select all columns first to have Power BI evaluate every column at once.
- Programmatic Steps in M: When writing more advanced queries, you might need to dynamically reference all columns to build a robust and future-proof transformation that won't break if the source data structure changes.
Method 1: The Quick Keyboard Shortcut (Ctrl + A)
By far the easiest and fastest way to select all your columns is with a familiar keyboard shortcut. This method is perfect for quick, manual edits directly in the Power Query Editor UI.
Here’s how it works:
- Open your query in the Power Query Editor (click on ‘Transform data’ on the Home Ribbon).
- In the data preview pane, click on the header of any single column to give it focus. The header will turn a darker gray to indicate it is selected.
- Now, press Ctrl + A on your keyboard (or Cmd + A if you're on a Mac).
Instantly, all column headers in your query will highlight, indicating they are all selected. From here, you can right-click on any of the selected headers or use the Transform tab in the ribbon to apply your desired transformation to every column simultaneously.
When to use this method: Use Ctrl-A for immediate, one-off tasks where you're working directly with the data you see in front of you. It's the go-to method for manual tasks and is easy for beginners to remember.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Method 2: The Shift-Click Method for Range Selection
If you prefer using your mouse or have a massive number of columns where scrolling is necessary, the Shift-Click method works just as well. This technique is common across many applications and allows you to select a continuous range of items - in this case, all columns from the first to the last.
Follow these steps:
- With your query open, click the header of the very first column in your table (the leftmost column).
- Scroll horizontally all the way to the last column.
- While holding down the Shift key on your keyboard, click the header of the last column.
This action selects the first column, the last column, and every single column between them. All column headers should now be highlighted. It achieves the same result as Ctrl + A but is a bit more visual and deliberate.
When to use this method: The Shift-Click method is great if you're a visual person who likes to confirm the start and end of what you're selecting. It's also useful if for some reason your keyboard shortcuts are not working.
Method 3: Programmatic Selection with M Code
While the first two methods are great for interactive, manual changes, their major drawback is that they create "hard-coded" steps in your query. For example, if you select all columns and then tell Power BI to change the data type, the generated M code will list every single one of those column names. If a new column is added to your source data later, it will be ignored by this step when you refresh.
To create a truly robust and dynamic solution, we need to turn to M, the language that powers Power Query. By writing some simple M code, you can tell Power BI to dynamically identify and select all columns, ensuring your query never breaks because of source data changes.
We’ll look at a key M Function for accomplishing this: Table.ColumnNames.
Dynamically Listing All Columns with Table.ColumnNames
The Table.ColumnNames() function is a fundamental part of working programmatically with table structures in M. Its job is simple: it inspects a table and returns a list of all its column names as text values.
You can see how this works by adding a custom step to your query:
- Have a query loaded in the Power Query Editor. Go to the last successfully-run Step in the Applied Steps panel and select it. This is your starting point.
- Click the ƒx button in the formula bar to insert a new step. This will start a new line of M code which initially just references the previous step’s name. For this example let’s assume the previous step is named
#"Changed Type". Your M formula bar will appear as= #"Changed Type". - Now modify the M in your formula bar to this and press enter:
= Table.ColumnNames(#"Changed Type")Instead of your table, the Power Query Editor will now display a single-column list that contains the names of every column from your previous step. While this step doesn’t select your columns in the traditional sense, it’s the building block for doing just that in a dynamic way.
You may also view and do this directly in the Advanced Editor:
let
Source = Csv.Document(...),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"ID", Int64.Type}, {"Name", type text}}),
// This step gets that list of column names dynamically.
ListOfColumnNames = Table.ColumnNames(#"Changed Type")
in
ListOfColumnNamesFree PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Using the Dynamic List for Transformations
Once you have a dynamic list of column names, you can use it as an input for other M functions, like Table.SelectColumns or Table.TransformColumnTypes. An extremely practical use case is changing all columns to a "Text" format before cleaning.
Let's stay in the Advanced Editor to write an M code based step. Manually doing this from the interface would generate code that explicitly names every column. If a column is added or removed from the source, your query refresh will likely fail.
Here’s the dynamic M code approach instead:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("...", BinaryEncoding.Base64), Compression.Deflate))),
PromotedHeaders = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
// 1. Get a list of all current column names
CurrentColumnNames = Table.ColumnNames(PromotedHeaders),
// 2. Create the correctly formatted list for the transformation function
// It needs a list of lists, like {{"Column1", type text}, {"Column2", type text}}
TransformationsList = List.Transform(CurrentColumnNames, each {_, type text}),
// 3. Apply the transformation using the dynamic list
ChangedAllToText = Table.TransformColumnTypes(PromotedHeaders, TransformationsList)
in
ChangedAllToTextIn this example:
CurrentColumnNamesusesTable.ColumnNames()to get a list like{"ID", "Name", "Date", "Region"}.TransformationsListusesList.Transform()to turn that simple list into the structure thatTable.TransformColumnTypesrequires. The code reads as “For each item in the list of column names, create a new sub-list containing that item and the valuetype text.”- Finally,
ChangedAllToTextapplies the change.
This query will now never fail due to column name changes. If a new column "Country" is added to the source, the query will automatically pick it up and convert it to text without you ever needing to edit the step.
Which Method Should You Choose?
All three methods effectively select every column, but the best one depends on your goal.
- Use Ctrl + A or Shift-Click when:
- Use the M Code method when:
Final Thoughts
Selecting all columns in a Power BI query is a foundational task with a few different approaches. For quick and simple jobs, stick with the Ctrl + A keyboard shortcut, but when you need to build robust and automated reports that last, learning how to use M functions like Table.ColumnNames will make a massive difference to how robust and fault-tolerant your reports can be.
Building your data expertise in tools like Power BI is a valuable investment, but we know much of that time is spent repeating the same work to prep data and build reports. That’s why we created Graphed. We automate the entire process by connecting directly to your sources, letting you create real-time dashboards and reports simply by describing what you need in plain English - no manual steps or M code needed.
Related Articles
Facebook Ads for Landscapers: The Complete 2026 Strategy Guide
Learn how to run profitable Facebook ads for landscapers in 2026. This complete guide covers audience targeting, ad formats, budgeting, and optimization strategies to generate leads at $30-50 per lead.
Facebook Ads for Painters: The Complete 2026 Strategy Guide
Learn how to run profitable Facebook ads for painters in 2026. This complete guide covers audience targeting, ad formats, budgeting, and optimization strategies to generate leads at $20-60 per lead.
Facebook Ads for Chiropractors: The Complete 2026 Strategy Guide
Discover how chiropractic practices can leverage Facebook advertising to attract new patients in 2026. Learn the top strategies, compliance requirements, and proven ad templates that drive appointments.