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 August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Adding column automaticly

Hey all,

I have a problem when i try to add a column in excel in the last one and when i refresh the data flow relative with sharepoint path. It can not be added because in the first 4 excel doesnt exist this column and i have to write manually. I can do that for 4 excel but after 100 excel and if we want to add add one more column in 101 excel i have to write all filter again and again. How can I add a column automaticly. I mean i want to create a function which helps to scan every column and if there is a value bring this value in any case if there is not value, i dont want to see this null column.

 

dodurukan_0-1680087557811.png

 

2 REPLIES 2
Anonymous
Not applicable

Hi @v-jingzhang,

Thank you so much for answer. However it didnt work tho. Actually I used 2 source transformation and inside of one source I am using a function that I work on it. I have to fix this function than it will work for sure. I want to bring datetime, attribute and value column as well.

 

My excel table is someting like this = 

dodurukan_1-1680702714221.png

 

and I´d like to add one more column in the last excel file for example B005 but although there is no column something like b005 in the last excel files so i am getting error like there is no column which is B005 so we it can´t bring this column as well.

 

Here you can see my function and i tried to apply it but it didn´t work. If you help me further, I will be really appreciated.

dodurukan_0-1680702661954.png

 

v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

You can use Table.ColumnNames function to get all existing column names of a table and check whether a column exists among them. 

 

Add a custom step in the formula bar with below code and modify "previous step" accordingly. When the column you are finding exists, it will return the table as it is. When the column doesn't exist, it will add a column with this column name. I'm not sure what result you want to add in the new column so I use null as an example. You can modify the results per your need. 

= if List.Contains(Table.ColumnNames(#"previous step"), "findingColumnName") then #"Changed Type" else Table.AddColumn( #"previous step", "findingColumnName", each null)

vjingzhang_0-1680237850547.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.