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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have two columns called "shipping_state" and "shipping_city".
If shipping_state has blanks, I want Power Query to cross check what is the text value in the same row under shipping_city and for example, if shipping_city has text of "Newark", it will replace the value of shipping_state with "New Jersey. This is my code, there are no syntax errors or running errors, but it does not give me the output on the shipping_state column. Appreicate if someone can help me out!
#"Replace States" = Table.ReplaceValue(#"Filtered Rows2", each if [shipping_state] = "" then
if [shipping_city] = "Newark" then "New Jersey"
else if [shipping_city] = "Stamford" then "Connecticut"
else [shipping_state]
else [shipping_state],
each [shipping_state],
Replacer.ReplaceValue,
{"shipping_state"}
)
in
#"Replace States"
Solved! Go to Solution.
@Anonymous
replacements =
[Newark = "New Jersey",
Stamford = "Connecticut"],
#"Replace States" = Table.ReplaceValue(
#"Filtered Rows2",
"", each Record.FieldOrDefault(replacements, [shipping_city], null),
(v, o, n) => if v = "" then n else v,
{"shipping_state"}
)
in
#"Replace States"
@Anonymous
replacements =
[Newark = "New Jersey",
Stamford = "Connecticut"],
#"Replace States" = Table.ReplaceValue(
#"Filtered Rows2",
"", each Record.FieldOrDefault(replacements, [shipping_city], null),
(v, o, n) => if v = "" then n else v,
{"shipping_state"}
)
in
#"Replace States"
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.