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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Query editor replacing column values based on another column values

Hi,

 

I have Rain, QA columns in the table.

 

RainQA
1.5null
0.510
0.7null
00.5

I am trying to change the Rain column values to "0" if the QA column contains any "nonnull" values.

 

 I am looking for below changes in the query editor

 

If [QA]!=null then [RAIN]=0 else [RAIN]

 

Expected Result:

RainQA
1.5null
010
0.7null
00.5

 

 

I wrote below code in Advanced editor, which is not giving me the result that I expected.

 

#"Replaced Value" = Table.ReplaceValue(#"5 min Rain fall",each [RAIN], each if [QA]<>"null" then 0 else [RAIN],Replacer.ReplaceValue,{"RAIN"})

 

Please let me know how to achieve this.

 

Thank you!

 

Regards,

Aswini

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Right on the column in data transformation mode. Choose replace

from : null

to : 0

 

null is take as null or blank value

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@Anonymous as @MFelix  suggested you can add a new custom column with the logic and remove the old rain column or you can update replace function like below and that will work as well.

 

 

= Table.ReplaceValue(#"Changed Type",each [Rain],each if [QA]=null then 0 else [Rain],Replacer.ReplaceValue,{"Rain"})

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

MFelix
Super User
Super User

Hi @Anonymous,

 

Your first code should work, except for the exclamation point.

 

Add a new column with the following code

 

If [QA]=null then [RAIN]=0 else [RAIN]

 

Be aware that you are creating a new column so you may need to delete the rain Column and rename this new one if you only want a rain Column on your model. 

If ir returns an error can you please tell what it is. 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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