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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
croufspesi
Frequent Visitor

Add column to data set using append

I have a pbix set to append files from within a folder. Folder currently contains 3 files

 

2018 Revenue

2019 Revenue

2020 Revenue

 

I have added 2 additional columns to the end of the data set in only the 2020 Revenue file and cannot get them to load.

 

- Refresh does not bring them in.

- Choose columns in query editor does not display them.

- Other strings in here recommended adjusting the # of columns within the Advanced Editor, but I cannot find a reference to a number of columns within the code in my file.

 

Can I add columns to just one of the files that is appending?  Or do added columns need to be added to all 3 of my files?

8 REPLIES 8
amitchandak
Super User
Super User

@croufspesi , Open your data in data transformation and right-click on the table name and open advance editor

You will see the script

 

 

let
    Source = Excel.Workbook(File.Contents("..\salesAfter regdate.xlsx"), null, true),
    sales_Sheet = Source{[Item="sales",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(sales_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Sales_Rep", type text}, {"Sales_Date", type date}, {"Units", Int64.Type}})
in
    #"Changed Type"

 

 

 

Add columns and datatype to check

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
Ashish_Mathur
Super User
Super User

Hi,

If you will not be adding columns regularly, then go to the Query Editor > View > Advanced Editor and edit the line there which has the column names to include the 2 new columns that you added.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur 

I do not see any of my current column names within the code.  

 

 

 

let
Source = Folder.Files("F:\E-Marketing\Numbers\PowerBI\Annual Sales Data - Copy"),
#"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
#"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File", Table.ColumnNames(#"Transform File"(#"Sample File"))),

Hi,

Follow the technique shown in this video.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
edhans
Super User
Super User

When you combine files, it takes a sample file that you pick, usually the first file. If that file doesn't have that column, it won't bring it in by default.

 

You can fix that though. Honestly, unless you are pretty good with Power Query, it might be easire to redo the Combine operation and pick the 3rd file vs the 1st file as the sample.

You can do it manually though by changing the index number of the sample file shown below. Change the {0} to {2} (it indexes at zero, then look at the Transform Sample File operation, and the other steps it created in your main query so it doesn't wind up removing the column after it brings it in.

 

2020-05-18 15_17_36-Untitled - Power Query Editor.png



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

@edhans 

 

EDIT: I got it!

 

at first, I tried to edit to the 2 within the code bar - that resulted in errors.

but when I opened that step in the advanced editor and changed it to the 2, it all fell in line perfectly.  

 

 

thanks thanks!!

Excellent @croufspesi - glad you got it sorted out.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

@edhans 

When changing the 0 to a 2, I get an error:  Expression.Error: We cannot convert a value of type Table to type Binary.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.