Example output
Hello! I can definitely help you with that. To unpivot the table, follow these steps:
1. Select the entire table including the headers.
2. Go to the "Transform Data" tab in the ribbon and click on "Unpivot Columns".
3. A new column will be created with the header "Attribute" and another column with the header "Value". Rename the "Attribute" column to "Month/Year" and the "Value" column to "Hours".
4. Click on "Close & Load" to load the new table into the worksheet.
To group by the total number of hours per each employee on the year, you can follow these steps:
1. Right-click on the "Month/Year" column and select "Insert Custom" > "Year".
2. Right-click on the "EID" column and select "Group By".
3. In the "Group By" dialog box, select "Year" and "EID" and then click on "OK".
4. A new table will be created with the total number of hours for each employee in each year.
To delete all the hours that are below 50 for a single month using M code, you can use the following code:
let Source = <Your data source>, #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {"EID"}, "Month/Year", "Hours"), #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Columns",{{"Month/Year", type date}, {"Hours", type number}}), #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Hours] >= 50 or Date.Month([Month/Year]) <> 1)) in #"Filtered Rows"
Replace <Your data source> with the reference to your original table. This code unpivots the table and filters out all the rows with hours below 50 for January. If you want to change the month, replace Date.Month([Month/Year]) <> 1 with Date.Month([Month/Year]) <> <Month number> where <Month number> is the number of the month you want to filter.