Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello Communty.
I have made some transformation to an excel file.
I would like to apply these transformations to any other files with about the same strucure.
The issue is that the amount of columns is not always the same. Therefore, in my query, when I move a custom column to the bigining, the query breaks because on the new file, it does not find for example the column 5 (The column 'Column5' of the table wasn't found.)
Let's say I have the below dataset on whicj I applied the transformations :
Column1 | Column2 | Column3 | Column4 |
brand | 01/01 | 01/02 | 01/03 |
Xyz | 500 | 200 | 200 |
DUM | 100 | 200 | 100 |
after I create a custom column that seats next to Column4, I move it to the begining.
= Table.ReorderColumns(#"Added Conditional Column",{"Custom", "Column1", "Column2", "Column3", "Column4"})
Now if I apply the same query step on the below dataset, my query breaks:
Column1 | Column2 | Column3 | Column4 | Column5 |
brand | 01/01 | 01/02 | 01/03 | 01/03 |
FUM | 100 | 200 | 200 | 400 |
RIM | 200 | 200 | 100 | 500 |
How could I solve this issue?
Thanks,
Chris
Solved! Go to Solution.
We started with Table.AddColumn, now it's Table.DuplicateColumn. Okay. Try this
= Table.ReorderColumns(#"Duplicated Column",{"Column1 - Copy"} & List.Difference(Table.ColumnNames(#"Duplicated Column"), {"Column1 - Copy"}))
If someone would find this post and having the same kind of question, I found this video that is very helpfull:
Hi @AlienSx , thanks for your reply. Do you replace the "source" term by your actual source? whether I replace the term source or I leave it as it is, I get an error.
If I use the query as it is above, I get Expression.Error: The column 'Name' of the table wasn't found.Details:
Name
thanks
the one that was modified by
#"Added Conditional Column"
so this is my step : = Table.ReorderColumns(#"Duplicated Column",{"Column1 - Copy"} & Table.ColumnNames("C:\Users\CC\Drive\ABC\ABC.xlsx")).
But somehow I get an error
We started with Table.AddColumn, now it's Table.DuplicateColumn. Okay. Try this
= Table.ReorderColumns(#"Duplicated Column",{"Column1 - Copy"} & List.Difference(Table.ColumnNames(#"Duplicated Column"), {"Column1 - Copy"}))
Hi, @Chrisjr
= Table.ReorderColumns(#"Added Conditional Column",{"Custom"} & Table.ColumnNames(Source))
where Source is your original table.
Check out the July 2025 Power BI update to learn about new features.