Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hello,
I am not sure where the mistake is in the following nested if statement. The query searches for a string in column3. Then it validates column5 and column6 to decide if the value of column4 is to be replaced.
Solved! Go to Solution.
Hi @ashraf999 ,
Please try:
= Table.ReplaceValue(#"Changed Type",each [Column4],
each if Text.Contains([Column3],"Instant Payment BSF/MBK") then
if (Value.Is(try Number.FromText([Column5]) otherwise null, type number)) then [Column5]
else if (Value.Is(Number.FromText([Column6]), type number)) then [Column6]
else [Column4]
else [Column4],Replacer.ReplaceValue,{"Column4"})
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
I don't see the Else for the IF highlighted in the pic above.
Rule of thumb: nr of IFs should equal nr of ELSEs 😁
I tried your suggestion by using this code:
= Table.ReplaceValue(#"Changed Type",each [Column4],
each if Text.Contains([Column3],"Instant Payment BSF/MBK") then
if (Value.Is(Number.FromText([Column5]), type number)) then [Column5]
else if (Value.Is(Number.FromText([Column6]), type number)) then [Column6]
else [Column4]
else [Column4],Replacer.ReplaceValue,{"Column4"})
However, it is not giving the results I want. Here is a sample of the data. As you can see records 21 & 22 should be replaced by the values in Column6:
Hi @ashraf999 ,
Please try:
= Table.ReplaceValue(#"Changed Type",each [Column4],
each if Text.Contains([Column3],"Instant Payment BSF/MBK") then
if (Value.Is(try Number.FromText([Column5]) otherwise null, type number)) then [Column5]
else if (Value.Is(Number.FromText([Column6]), type number)) then [Column6]
else [Column4]
else [Column4],Replacer.ReplaceValue,{"Column4"})
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 14 | |
| 14 | |
| 12 | |
| 7 | |
| 6 |