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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
jgpbi
Helper I
Helper I

Limit columns of import from a spreadsheet

I have a report template that generates output based on a spreadsheet. The template is used over and over again but each time with a different source file.

 

The spreadsheet is created by a well known tool but does not always have the exact same columns.(depending on what version you use)

 

This means I have source of input that may have a varied number of columns. 

 

Is there a way to handle columns that may exist in one source file and not another? I can't just delete them in Power Query as the next import will try to delete a column that may not exist.

 

My only option today is to manually edit the columns of each spreadsheet and add or remove the ones needed.

 

1 ACCEPTED SOLUTION

@jgpbi , Append column in power query can help, it only append if column name are not same, But you can choose what column you finally want

 

refer example

https://learn.microsoft.com/en-us/powerquery-m/table-combine

 

Table.Combine(
    {
        Table.FromRecords({[Name = "Bob", Phone = "123-4567"]}),
        Table.FromRecords({[Fax = "987-6543", Phone = "838-7171"]}),
        Table.FromRecords({[Cell = "543-7890"]})
    },
    {"CustomerID", "Name"}

 

 

Table.Combine: https://youtu.be/YdqOypKHsRU

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@jgpbi , consider these two functions for rename and column transformation, which can help

 

https://learn.microsoft.com/en-us/powerquery-m/table-transformcolumnnames

https://learn.microsoft.com/en-us/powerquery-m/table-transformcolumns

 

you have the option to ignore

 

Table.TransformColumnNames - https://youtu.be/qz5g35fnHKk

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  - Thank you. That helps me with a different problem. I did not see an 'ignore' option in that demo.

The issue I am having here is:

Source files are nearly identical. Some have more or less columns.

Source 1 - Column Names - Column-Name1, Column-Name2, Column-Name5, Column-Name6

Source 2 - Column Names - Column-Name1, Column-Name2, Column-Name3, Column-Name6

I only need Columns 1, 2and 6.

 

In my case there are almost 100 columns in the source and I only need 8 of them.

 

@jgpbi , Append column in power query can help, it only append if column name are not same, But you can choose what column you finally want

 

refer example

https://learn.microsoft.com/en-us/powerquery-m/table-combine

 

Table.Combine(
    {
        Table.FromRecords({[Name = "Bob", Phone = "123-4567"]}),
        Table.FromRecords({[Fax = "987-6543", Phone = "838-7171"]}),
        Table.FromRecords({[Cell = "543-7890"]})
    },
    {"CustomerID", "Name"}

 

 

Table.Combine: https://youtu.be/YdqOypKHsRU

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.