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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
smithmc3
Advocate I
Advocate I

Query editor replacing values based on another column

I am trying to change the subdivision name from "Asset Management" to "Land Use Office" for those items where the the department is "land use office"  I can't figure out the query editor language, see below.  Everything works great up to the "Replaced LandUse", mainly because everything else is done straight throught the basic user interface edits. 

------

let
Source = 
#"Use First Row As Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Change Type" = Table.TransformColumnTypes(#"Use First Row As Headers",{{"EmplID", type text}, {"Name", type text}, {"District", type text}, {"Subdivision Code", Int64.Type}, {"Subdivision Name", type text}, {"FileDate", type datetime}}),
#"Filtered Rows" = Table.SelectRows(#"Change Type", each ([District] <> "")),
#"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"EmplID", Int64.Type}, {"FileDate", type date}}),
#"Replaced CDP" = Table.ReplaceValue(#"Changed Type","Learning Center","Core Development Program",Replacer.ReplaceText,{"Subdivision Name"}),
#"Replaced ACO" = Table.ReplaceValue(#"Replaced CDP","Audit","Assurance & Compliance Office",Replacer.ReplaceText,{"Subdivision Name"}),
#"Replaced OTP3" = Table.ReplaceValue(#"Replaced ACO","PPTA","Office of Transportation Public-Private Partnerships",Replacer.ReplaceText,{"Subdivision Name"}),
#"Replaced LandUse" = Table.ReplaceValue(#"if({"Department", type text}="Land Use Office" then Table.ReplaceValue(#"Replaced OTP3", "Asset Management", "Land Use Office",Replacer.ReplaceText,{"Subdivision Name"}) else {"Subdivision Name"}="Asset Management")")
in
#"Replaced LandUse"

1 ACCEPTED SOLUTION

We ended up just adding a custom calculated column to do make the adjustment.  See text below.  To make it a little cleaner, we will add the other replace value steps into the custom calculated colum.

 

#"Added Custom" = Table.AddColumn(#"Replaced OTP3", "Res", each if [Department] = "Land Use Office" then "Land Use Office" else [Subdivision Name]),

View solution in original post

2 REPLIES 2
Vvelarde
Community Champion
Community Champion

@smithmc3

 

Hi, Try using a Conditional Column in the Query Editor.

 

 

 

 




Lima - Peru

We ended up just adding a custom calculated column to do make the adjustment.  See text below.  To make it a little cleaner, we will add the other replace value steps into the custom calculated colum.

 

#"Added Custom" = Table.AddColumn(#"Replaced OTP3", "Res", each if [Department] = "Land Use Office" then "Land Use Office" else [Subdivision Name]),

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.