Reputation: 79
I was creating a new query in power query and opened advanced editor to tweak one of the steps. The query works fine but all the steps have disappeared from the "Applied Steps" menu on the right and merged into a single step.
How do I break these into small steps again (which is a lot simpler to understand and troubleshoot)?
Does this happen every time the advanced editor is used?
My code below. Can I somehow have each line show as a separate step in the "applied steps" menu on the right?
let
Source = Excel.CurrentWorkbook(){[Name="FlagsAllClients"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Portfolio Manager", type text}, {"Client ID", type text}, {"Client Name", type text}, {"KE", type text}, {"Portfolio ID", type text}, {"Days Out", Int64.Type}, {"Risk Category", type text}, {"Risk", type text}, {"Tracking Error", type text}, {"Concentration", type text}, {"Sector", type text}, {"Buy-List", type text}, {"Max Hld Wt", type text}, {"Anom. Hldgs", type text}, {"Concentration Issuer", type text}, {"Portfolio Value", type number}, {"Date", type datetime}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type",{"Portfolio Manager"},BD_Office,{"BG"},"BD_Office",JoinKind.LeftOuter),
#"Expanded BD_Office" = Table.ExpandTableColumn(#"Merged Queries", "BD_Office", {"Team"}, {"BD_Office.Team"}),
#"Merged Queries1" = Table.NestedJoin(#"Expanded BD_Office",{"Client ID"},FlagsT,{"Client ID"},"FlagsT",JoinKind.LeftOuter),
#"Expanded FlagsT" = Table.ExpandTableColumn(#"Merged Queries1", "FlagsT", {"Risk", "Sector", "Buy-List", "Max Hld Wt"}, {"FlagsT.Risk", "FlagsT.Sector", "FlagsT.Buy-List", "FlagsT.Max Hld Wt"}),
#"Merged Queries2" = Table.NestedJoin(#"Expanded FlagsT",{"Client ID"},FlagsT_1,{"Client ID"},"FlagsT_1",JoinKind.LeftOuter),
#"Expanded FlagsT_1" = Table.ExpandTableColumn(#"Merged Queries2", "FlagsT_1", {"Risk", "Sector", "Buy-List", "Max Hld Wt"}, {"FlagsT_1.Risk", "FlagsT_1.Sector", "FlagsT_1.Buy-List", "FlagsT_1.Max Hld Wt"}),
#"Removed Other Columns" = Table.SelectColumns(#"Expanded FlagsT_1",{"Portfolio Manager", "Client ID", "Client Name", "KE", "Portfolio Value", "BD_Office.Team", "FlagsT.Risk", "FlagsT.Sector", "FlagsT.Buy-List", "FlagsT.Max Hld Wt", "FlagsT_1.Risk", "FlagsT_1.Sector", "FlagsT_1.Buy-List", "FlagsT_1.Max Hld Wt"}),
#"Reordered Columns" = Table.ReorderColumns(#"Removed Other Columns",{"BD_Office.Team", "Portfolio Manager", "Client ID", "Client Name", "KE", "Portfolio Value", "FlagsT.Risk", "FlagsT.Sector", "FlagsT.Buy-List", "FlagsT.Max Hld Wt", "FlagsT_1.Risk", "FlagsT_1.Sector", "FlagsT_1.Buy-List", "FlagsT_1.Max Hld Wt"}),
#"Replaced Value" = Table.ReplaceValue(#"Reordered Columns","X","1",Replacer.ReplaceValue,{"FlagsT.Risk","FlagsT.Sector","FlagsT.Buy-List","FlagsT.Max Hld Wt","FlagsT_1.Risk","FlagsT_1.Sector","FlagsT_1.Buy-List","FlagsT_1.Max Hld Wt"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","!","0",Replacer.ReplaceText,{"FlagsT.Risk","FlagsT.Sector","FlagsT.Buy-List","FlagsT.Max Hld Wt","FlagsT_1.Risk","FlagsT_1.Sector","FlagsT_1.Buy-List","FlagsT_1.Max Hld Wt"}),
#"Replaced Value2" = Table.ReplaceValue(#"Replaced Value","2","0",Replacer.ReplaceText,{"FlagsT.Risk","FlagsT.Sector","FlagsT.Buy-List","FlagsT.Max Hld Wt","FlagsT_1.Risk","FlagsT_1.Sector","FlagsT_1.Buy-List","FlagsT_1.Max Hld Wt"})
in
#"Replaced Value1"
Upvotes: 0
Views: 823
Reputation: 79
Basically, I failed to reference previous step in power editor. Explanation that helped me understand what I was doing wrong was posted on https://social.technet.microsoft.com/Forums/en-US/bfe0e2e4-16e0-4d76-b3b9-27a43ce27866/excel-power-query-advanced-editor-breaking-code-into-steps?forum=powerquery
Power query code is typically written like this:
let
step1 = blah blah,
step2 = blah(step1 blah),
step3 = blah(step2, blah)
in
step3
So if you add a new step, remember that the next steps have to reference it, and the step at the last line after "in" should be the last step. You probably forgot to change the step name after "in"
Upvotes: 1
Reputation: 40204
I think the issue here is that your in
reference in the very last line is referring to the second to last step in the M code. If you change in #"Replaced Value1"
to in #"Replaced Value2"
I suspect it will behave more like you'd expect.
You probably also want the #"Replaced Value2"
line to reference #"Replaced Value1"
rather than a second reference to #"Replaced Value"
.
Upvotes: 1