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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Pointbreak5
New Member

Replacing a specific value in ALL cells, without having to specify column names?

I'm dealing with a single table / CSV file where they used the '-' character as a replacement for lack of value (instead of leaving it empty). I guess it's meant to stand for Not Applicable. It throws off PowerBI since it can't apply a numerical column type when this character is detected in a column that is otherwise numbers.

I can't fix the data at the source, and repairing it locally doesn't help since my goal is sharing my PowerBI reports with people who will point it at their own local data which they can't be expected to repair.

I'd like to perform a search-and-replace on the entire table during the data import step, prior to assigning a data type to the columns. I figured out how to do it if I explicitly specify the column names:

 

 

= Table.ReplaceValue(#"PreviousStep","-","",Replacer.ReplaceValue,{"Source.Name", "Column 1", "Column 2 ", "Column N"})

 

 

...but I don't want to make assumptions about column names in the step, because they can differ depending on the version of the tool that produced this CSV file. Plus there's about 500 columns in the CSV sample I'm working with.

So how can I rewrite the above in a way that enumerates over the column names without explicitly naming them?

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @Pointbreak5,

If you want to do this completely indiscriminately across all columns in your query, just use Table.ColumnNames to pass in the list of all columns from #PreviousStep, where you're passing your hard-coded column names, e.g.:

= Table.ReplaceValue(#"PreviousStep","-","",Replacer.ReplaceValue,Table.ColumnNames(#"PreviousStep"))

 Here's a simple table I have to hand:

image.png

I can then use this to replace all occurences of 'E' with '___' across all columns, e.g.:
image.png

Hopefully this is all you need. Good luck!

Daniel


If my post solves your challenge, then please consider accepting as a solution to help other forum members find the answer more quickly 🙂





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

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

1 REPLY 1
dm-p
Super User
Super User

Hi @Pointbreak5,

If you want to do this completely indiscriminately across all columns in your query, just use Table.ColumnNames to pass in the list of all columns from #PreviousStep, where you're passing your hard-coded column names, e.g.:

= Table.ReplaceValue(#"PreviousStep","-","",Replacer.ReplaceValue,Table.ColumnNames(#"PreviousStep"))

 Here's a simple table I have to hand:

image.png

I can then use this to replace all occurences of 'E' with '___' across all columns, e.g.:
image.png

Hopefully this is all you need. Good luck!

Daniel


If my post solves your challenge, then please consider accepting as a solution to help other forum members find the answer more quickly 🙂





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

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Kudoed Authors