To me it would seem easier to have the managers fill out the weekly tabs and then aggregate the data using Power Query and Power Pivot to produce the pivot table on the EmpHours sheet so that the data does not become misaligned..
1. Produce a list of distinct ID's using the following Power Query code:
let
Source = Excel.CurrentWorkbook(),
#"Filtered Rows" = Table.SelectRows(Source, each ([Name] = "tbl_WK1" or [Name] = "tbl_WK2")),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Name"}),
#"Expanded Content" = Table.ExpandTableColumn(#"Removed Columns", "Content", {"Emoloyee ID"}, {"Emoloyee ID"}),
#"Removed Duplicates" = Table.Distinct(#"Expanded Content"),
#"Sorted Rows" = Table.Sort(#"Removed Duplicates",{{"Emoloyee ID", Order.Ascending}}),
#"Changed Type" = Table.TransformColumnTypes(#"Sorted Rows",{{"Emoloyee ID", Int64.Type}})
in
#"Changed Type"
2. Make connections to both the WK1 and WK2 tables using:
let
Source = Excel.CurrentWorkbook(){[Name="tbl_WK1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Emoloyee ID", Int64.Type}, {"Office", type text}, {"Last", type text}, {"First", type text}, {"WK1 Total", Int64.Type}, {"M", Int64.Type}, {"TU", Int64.Type}, {"W", Int64.Type}, {"TH", Int64.Type}, {"F", Int64.Type}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"M", "TU", "W", "TH", "F"})
in
#"Removed Columns"
3. Append the connections to the two tables using:
let
Source = Table.Combine({tbl_WK1, tbl_WK2})
in
Source
4. Load the UniqeIDs table and the Append table to the data model
5. In the Diagrams View of the data model produce a connection between the Employee ID fields of the two tables
6. Produce the Pivot Table seen on the EmpHours sheet
Note that when new data is added to either the WK1 or WK2 tables you can select a cell in the Pivot Table and then refresh.
Note that connections will need to be produced for tbl_WK3 and tbl_WK4 when that data becomes available.
Let us know if you have any questions.
Bookmarks