cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
powerqueryquest
Regular Visitor

Replace values in all columns with a formula (Cleaning negative values denoted by brackets)

A table imported from PDF has negative values denoted with one right bracket, like this "6,964.68)". (The left bracket has been placed in a separate column due to the way Power Bi does text to table translation.)

 

I'm trying to replace all values containing ")" with a cleaned and negative version of the value. (ie. "6,964.68)" would become "-6,964.68".

 

Importantly, because this is for a large data set, I'm trying to achieve this:

A: Without creating a helper column and

B. Without referring to specific column names

 

This code works:
= Table.ReplaceValue(#"Filtered Rows",
each [Column9],
each if Text.Contains([Column9],")")
then "-" & Text.Replace([Column9],")","")
else [Column9],
Replacer.ReplaceText,
Table.ColumnNames(#"Filtered Rows"))


This doesn't:
= Table.ReplaceValue(#"Filtered Rows",
each Table.ColumnNames(#"Filtered Rows"),
each if Text.Contains(Table.ColumnNames(#"Filtered Rows"),")")
then "-" & Text.Replace(Table.ColumnNames(#"Filtered Rows"),")","")
else Table.ColumnNames(#"Filtered Rows"),
Replacer.ReplaceText,
Table.ColumnNames(#"Filtered Rows"))

1 REPLY 1
v-zhangti
Community Support
Community Support

Hi, @powerqueryquest 

 

You can try to use Split in Power query.

vzhangti_0-1652681986292.png

The separated blank columns are deleted directly.

vzhangti_1-1652682020634.png

Convert the format to Text first. add custom columns.

vzhangti_2-1652682406179.png

Then convert the format to digital format.

vzhangti_3-1652682494627.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors