Forum Discussion
Replace value based on conditions from multiple columns
can you share the actual error you are getting? are you able to provide the whole script?
- TCatron181 year ago
Helper II
vanessafvg It appears that it doesn't like the columns being in square brackets and wants them to be in quotations instead.
This is the whole script minus the step that I'm having issues with:
let
Source = Excel.Workbook(File.Contents("S:\HRIS\Reporting\Analytics\Honoring YOU\Access DB\All_Awards.xlsx"), null, true),
data0_Sheet = Source{[Item="data0",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(data0_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"AWARD ID", Int64.Type}, {"Date Submitted", type datetime}, {"Employee ID", Int64.Type}, {"RECIPIENT'S NAME", type text}, {"Recipient's Email", type text}, {"Award Type", type text}, {"Amount", Int64.Type}, {"Core Value", type text}, {"Reward Code", type any}, {"Patient Recognition", type text}, {"Award Status", type text}, {"Approve Date", type date}, {"RECIPIENT'S DIRECT MANAGER ID", Int64.Type}, {"RECIPIENT'S DEPARTMENT", Int64.Type}, {"RECIPIENT'S DEPARTMENT TITLE", type text}, {"Recipient's Affiliate", type text}, {"RECIPIENT'S HIRE DATE", type date}, {"Issuer Employee ID", type text}, {"Issuer's Name", type text}, {"Issuer's Email", type text}, {"ISSUER'S DIRECT MANAGER ID", Int64.Type}, {"Issuer's Manager Name", type text}, {"ISSUER'S DEPARTMENT TITLE", type text}, {"Sender's Affiliate", type text}, {"Delivery Method", type text}, {"Resolution Date", type datetime}, {"Sender Department ID", Int64.Type}}),
#"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Recipient's Affiliate"}, #"Senoir Affiliate Table", {"Affiliate"}, "Senoir Affiliate Table", JoinKind.LeftOuter),
#"Expanded Senoir Affiliate Table" = Table.ExpandTableColumn(#"Merged Queries", "Senoir Affiliate Table", {"Sr Business Unit"}, {"Senoir Affiliate Table.Sr Business Unit"}),
#"Renamed Columns" = Table.RenameColumns(#"Expanded Senoir Affiliate Table",{{"Senoir Affiliate Table.Sr Business Unit", "Recipient's Sr Business Unit"}}),
#"Merged Queries1" = Table.NestedJoin(#"Renamed Columns", {"Sender's Affiliate"}, #"Senoir Affiliate Table", {"Affiliate"}, "Senoir Affiliate Table", JoinKind.LeftOuter),
#"Expanded Senoir Affiliate Table1" = Table.ExpandTableColumn(#"Merged Queries1", "Senoir Affiliate Table", {"Sr Business Unit"}, {"Senoir Affiliate Table.Sr Business Unit"}),
#"Renamed Columns1" = Table.RenameColumns(#"Expanded Senoir Affiliate Table1",{{"Senoir Affiliate Table.Sr Business Unit", "Sender's Sr Business Unit"}}),
#"Replaced Value" = Table.ReplaceValue(#"Renamed Columns1",null,"xSystem Generated",Replacer.ReplaceValue,{"Sender's Affiliate"}),
#"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",null,"xSystem Generated",Replacer.ReplaceValue,{"Sender's Sr Business Unit"}),
#"Merged Queries2" = Table.NestedJoin(#"Replaced Value1", {"Issuer Employee ID"}, #"Manager Data", {"Employee"}, "Manager Data", JoinKind.LeftOuter),
#"Expanded Manager Data" = Table.ExpandTableColumn(#"Merged Queries2", "Manager Data", {"AssignmentIsSupervisor"}, {"Manager Data.AssignmentIsSupervisor"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Manager Data",{{"Manager Data.AssignmentIsSupervisor", type text}}),
#"Replaced Value2" = Table.ReplaceValue(#"Changed Type1",null,"Employee",Replacer.ReplaceValue,{"Manager Data.AssignmentIsSupervisor"}),
#"Renamed Columns2" = Table.RenameColumns(#"Replaced Value2",{{"Manager Data.AssignmentIsSupervisor", "Is a Manager"}}),
#"Changed Type2" = Table.TransformColumnTypes(#"Renamed Columns2",{{"Employee ID", type text}}),
#"Merged Queries3" = Table.NestedJoin(#"Changed Type2", {"Employee ID"}, #"Category Data", {"EMPLOYEE"}, "Category Data", JoinKind.LeftOuter),
#"Expanded Category Data" = Table.ExpandTableColumn(#"Merged Queries3", "Category Data", {"POSITIONCATEGORY", "JOBCATEGORY"}, {"Category Data.POSITIONCATEGORY", "Category Data.JOBCATEGORY"}),
#"Renamed Columns3" = Table.RenameColumns(#"Expanded Category Data",{{"Category Data.POSITIONCATEGORY", "Recipient's Position Category"}, {"Category Data.JOBCATEGORY", "Recipient's Job Category"}}),
#"Merged Queries4" = Table.NestedJoin(#"Renamed Columns3", {"Issuer Employee ID"}, #"Category Data", {"EMPLOYEE"}, "Category Data", JoinKind.LeftOuter),
#"Expanded Category Data1" = Table.ExpandTableColumn(#"Merged Queries4", "Category Data", {"POSITIONCATEGORY", "JOBCATEGORY"}, {"Category Data.POSITIONCATEGORY", "Category Data.JOBCATEGORY"}),
#"Renamed Columns4" = Table.RenameColumns(#"Expanded Category Data1",{{"Category Data.POSITIONCATEGORY", "Sender's Position Category"}, {"Category Data.JOBCATEGORY", "Sender's Job Category"}})
in
#"Renamed Columns4"