Andi Erni
Andi Erni

Reputation: 563

Power Query replace values (enter step for potential future occurrence)

In the Power Query editor of Power BI I try to enter a replace value step for something that currently does not exist in the table. But I know that future versions of the table will include the thing that I will have to replace. However the editor gives me an error message because in the current version of the table that string I want to replace is not there. How can I solve this?

In detail it is a CSV file (daily updated) that from time to time will contain values that include a "thousands separator" (, in my case) and that "," I will have to replace by "" when it occurs.

Thanks for any help.

Upvotes: 0

Views: 438

Answers (2)

Peter
Peter

Reputation: 12315

I can't reproduce the problem either. Copy below query into the Advanced Editor and see yourself.

let
    Source = Table.FromRows(
        Json.Document(
            Binary.Decompress(
                Binary.FromText(
                    "i45WMjQ0MNYzNFWK1YlWMjIwMNCzNAGzTSwszcEMQz0jY6BQLAA=", 
                    BinaryEncoding.Base64
                ), 
                Compression.Deflate
            )
        ), 
        let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [number = _t]
    ),
    #"Replaced Value" = Table.ReplaceValue(
        Source,",","",Replacer.ReplaceText,{"number"}),
    #"Changed Type with Locale" = Table.TransformColumnTypes(
            #"Replaced Value", 
            {{"number", type number}}, 
            "en-US"
        )
in
    #"Changed Type with Locale"

Upvotes: 2

horseyride
horseyride

Reputation: 21318

That doesn't seem right. If you replace a string that does not exist then it just does nothing, it does not generate an error. Post your code if you want us to look at it otherwise potentially surround your code line with try and otherwise. Look it up

Upvotes: 2

Related Questions