Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
Hi,
I have Rain, QA columns in the table.
Rain | QA |
1.5 | null |
0.5 | 10 |
0.7 | null |
0 | 0.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:
Rain | QA |
1.5 | null |
0 | 10 |
0.7 | null |
0 | 0.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
@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.
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
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThis is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
70 | |
57 | |
37 | |
36 |
User | Count |
---|---|
85 | |
65 | |
60 | |
46 | |
45 |