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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Aureli
Frequent Visitor

Power query Replace Values

Hi,

I want to replace the value null for two different values in power query as you can see below:

Captura de pantalla 2022-12-01 101347.jpg

How can I do it?

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @Aureli ,

 

I think you can add this code in Advanced Editor in Power Query Editor.

...    
#"Replaced Value" = Table.ReplaceValue(#"Changed Type",null,each [Column9],Replacer.ReplaceValue,{"De 80-109 kg"})
...

Sample:

RicoZhou_1-1669966480549.png

The whole code in My Sample:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtJRMrIwU4rVATMtjCBMI0MDIM/MyEIpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"De 80-109 kg" = _t, Column9 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"De 80-109 kg", Int64.Type}, {"Column9", Int64.Type}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",null,each [Column9],Replacer.ReplaceValue,{"De 80-109 kg"})
in
    #"Replaced Value"

Result is as below.

RicoZhou_0-1669966453464.png


Best Regards,
Rico Zhou

 

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

 

 

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @Aureli ,

 

I think you can add this code in Advanced Editor in Power Query Editor.

...    
#"Replaced Value" = Table.ReplaceValue(#"Changed Type",null,each [Column9],Replacer.ReplaceValue,{"De 80-109 kg"})
...

Sample:

RicoZhou_1-1669966480549.png

The whole code in My Sample:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtJRMrIwU4rVATMtjCBMI0MDIM/MyEIpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"De 80-109 kg" = _t, Column9 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"De 80-109 kg", Int64.Type}, {"Column9", Int64.Type}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type",null,each [Column9],Replacer.ReplaceValue,{"De 80-109 kg"})
in
    #"Replaced Value"

Result is as below.

RicoZhou_0-1669966453464.png


Best Regards,
Rico Zhou

 

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

 

 

HotChilli
Super User
Super User

If there are only 2 rows in the table, it's straightforward, remove the column 80-109kg and rename Column9.

If it's more complex, post some data and any other desired result

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors