Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
pbyrne98
Regular Visitor

Table.RemoveColumns(Table, Table.Column.Values)

Someone is going to ROFL on this one.

Three queries:

1. Query 1 : Table with all columns in a CSV

2. Query 2 : Table with one column with list of columns I want to keep in query 1

3. Query 3 : Query 1 Table with all columns removed excluding column names in the table in Query 2.

 

What is the syntax for Table.RemoveColumns or KeepColumns that allow me to end up with Query 3?

1 ACCEPTED SOLUTION

That seemed to do the trick, in the end I referenced the original query (pm_project) to create a 'Source', add a customised step with the following command and voila 🙂

 

= Table.SelectColumns(Source, tblPACfields[pm_project_fields])

View solution in original post

5 REPLIES 5
wdx223_Daniel
Super User
Super User

Table.SelectColumns(Query1,Table.ToColumns(Query2){0},MissingField.UseNull)

BA_Pete
Super User
Super User

Hi @pbyrne98 ,

 

Try the following for your Table3 query:

let
    Source = Table.SelectColumns(Query1, Query2)
in
    Source

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Thanks Pete,

This is what pops up when I put it in, it maybe that the Query2 is a table and not a list?

 

Expression.Error: We cannot convert a value of type Table to type Text.
Details:
Value=[Table]
Type=[Type]

 

Added pictures of the Query 1, 2 and 3 to help.

 

Query1.jpg

 

Query2.jpg

 

Query3.jpg

 

Query3 Advanced Editor.jpg

 

 

   

 

 

You're nearly there. The issue is that tblPACfields is a table rather than a list like the function expects.

 

You can fix this by specifying the column from the table (since table columns are lists).

Table.SelectColumns(pm_project, tblPACfileds[pm_project_fields])

Or, assuming the query pm_project_fields is already the appropriate list (rather than a table).

Table.SelectColumns(pm_project, pm_project_fields)

 

That seemed to do the trick, in the end I referenced the original query (pm_project) to create a 'Source', add a customised step with the following command and voila 🙂

 

= Table.SelectColumns(Source, tblPACfields[pm_project_fields])

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.