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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
StephenF
Responsive Resident
Responsive Resident

Error handling on advanced editor?

Sometimes Column 2 here exists sometimes and sometimes is doesnt.

 

I want powerbi not to error out on refresh if it doesnt exist, how to do this?

 

#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Source.Name", "Column2"}),

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

@StephenF ,

 

You can use the function "Remove Other Columns", so you delete all the columns except those you are selecting.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

2 REPLIES 2
camargos88
Community Champion
Community Champion

@StephenF ,

 

You can use the function "Remove Other Columns", so you delete all the columns except those you are selecting.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



vanessafvg
Super User
Super User

you can first probably check if the column exists before you remove it

chris web has a way of check if a column exists

let
Source = Csv.Document(File.Contents("C:\MissingColumnDemo.csv"),[Delimiter=",",Encoding=1252]),
PromotedHeaders = Table.PromoteHeaders(Source),
CheckColumns = Table.HasColumns(PromotedHeaders, {"Column2"})
in
CheckColumns

https://blog.crossjoin.co.uk/2015/07/08/checking-columns-are-present-in-power-query/

or something like this

to which you add a custom column to your m query, and adapt this if statement to your requirements

https://social.technet.microsoft.com/Forums/en-US/87affbc4-364f-470a-80ee-c35d32f1d331/is-there-a-wa...

AddedCustom = if List.Contains(Table.ColumnNames(PreviousStepName), "Column2") then PreviousStepName else Table.RemoveColumn(PreviousStepName, "Column2", each ...





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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