cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
danielvidal
New Member

How changing the some of the values of a column (null) to the other values of the column condition

Hi,

 

I have 2 columns, first one, same value ( PO #) the other one 2 values (null) and a SO #. How can I change the value of null to be the same as the SO..considering there may be hundreds of POs and hundreds of scenarios in which there's a null value

 

PCPV

PC210639NO PV
PC210639NO PV
PC210639NO PV
PC210639NO PV
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639NO PV
PC210639NO PV
PC210639NO PV
PC210639NO PV
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560
PC210639PV210560

 

I have tried tones of things but I don't know how to tell power query to do this automatically for all cases

 

Cheers

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

Hi, @danielvidal ;

If i understand right , you could add a conditional column.

vyalanwumsft_1-1663142567945.png

 

Then delete orginal column.

vyalanwumsft_2-1663142585940.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCnA2MjQwM7ZU0lHy81cICFOK1aGmYEAYkGlqZjAqTpr4aFwMsLgCSigqYJNGCMQCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"PO #" = _t, #"SO #" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"PO #", type text}, {"SO #", type text}}),
    #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if [#"PO #"] = " " then [#"SO #"] else [#"PO #"]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"PO #"})
in
    #"Removed Columns"

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community


Best Regards,
Community Support Team _ Yalan Wu
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

1 REPLY 1
v-yalanwu-msft
Community Support
Community Support

Hi, @danielvidal ;

If i understand right , you could add a conditional column.

vyalanwumsft_1-1663142567945.png

 

Then delete orginal column.

vyalanwumsft_2-1663142585940.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCnA2MjQwM7ZU0lHy81cICFOK1aGmYEAYkGlqZjAqTpr4aFwMsLgCSigqYJNGCMQCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"PO #" = _t, #"SO #" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"PO #", type text}, {"SO #", type text}}),
    #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if [#"PO #"] = " " then [#"SO #"] else [#"PO #"]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"PO #"})
in
    #"Removed Columns"

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors