I am having difficulty with merging tables and multiple criteria. I would like to receive "Employee_Rates.True Cost Rate" from matching "Employee_Hours.Employee Name" to "Employee_Rates.Employee Name" and if "Employee_Rates.Start Date" is <= (less than or equal) to "Employee_Hours.Date Worked". I am merging another table into the query and all data is as expected until line #"Merged Queries". After this and #"Expanded Employee_Rates", the data is reduced to one line. The Employee_Hours table has duplicate names with different Start Dates for different True Cost Rates. The following is the code from the editor:
let
Source = Table.NestedJoin(Project_List, {"Project Number"}, Employee_Hours, {"Project Number"}, "Employee_Hours", JoinKind.LeftOuter),
#"Expanded Employee_Hours" = Table.ExpandTableColumn(Source, "Employee_Hours", {"Employee Name", "Date Worked", "Hours Worked "}, {"Employee_Hours.Employee Name", "Employee_Hours.Date Worked", "Employee_Hours.Hours Worked "}),
#"Reordered Columns" = Table.ReorderColumns(#"Expanded Employee_Hours",{"Project Description ", "Project Number", "Employee_Hours.Employee Name", "Employee_Hours.Date Worked", "Employee_Hours.Hours Worked "}),
#"Sorted Rows" = Table.Sort(#"Reordered Columns",{{"Project Description ", Order.Ascending}}),
#"Merged Queries" = Table.NestedJoin(#"Sorted Rows", {"Employee_Hours.Employee Name", "Employee_Hours.Date Worked"}, Employee_Rates, {"Employee Name", "Start Date"}, "Employee_Rates", JoinKind.Inner),
#"Expanded Employee_Rates" = Table.ExpandTableColumn(#"Merged Queries", "Employee_Rates", {"True Cost Rate"}, {"Employee_Rates.True Cost Rate"})
in
#"Expanded Employee_Rates"
I can do this within a spreadsheet, but in Power Query. Hopefully someone can provide some suggestion. And I hope this is enough information.
Thank you!
let
Source = Table.NestedJoin(Project_List, {"Project Number"}, Employee_Hours, {"Project Number"}, "Employee_Hours", JoinKind.LeftOuter),
#"Expanded Employee_Hours" = Table.ExpandTableColumn(Source, "Employee_Hours", {"Employee Name", "Date Worked", "Hours Worked "}, {"Employee_Hours.Employee Name", "Employee_Hours.Date Worked", "Employee_Hours.Hours Worked "}),
#"Reordered Columns" = Table.ReorderColumns(#"Expanded Employee_Hours",{"Project Description ", "Project Number", "Employee_Hours.Employee Name", "Employee_Hours.Date Worked", "Employee_Hours.Hours Worked "}),
#"Sorted Rows" = Table.Sort(#"Reordered Columns",{{"Project Description ", Order.Ascending}}),
#"Merged Queries" = Table.NestedJoin(#"Sorted Rows", {"Employee_Hours.Employee Name", "Employee_Hours.Date Worked"}, Employee_Rates, {"Employee Name", "Start Date"}, "Employee_Rates", JoinKind.Inner),
#"Expanded Employee_Rates" = Table.ExpandTableColumn(#"Merged Queries", "Employee_Rates", {"True Cost Rate"}, {"Employee_Rates.True Cost Rate"})
in
#"Expanded Employee_Rates"
I can do this within a spreadsheet, but in Power Query. Hopefully someone can provide some suggestion. And I hope this is enough information.
Thank you!