Forum Discussion
Staff roster from table to a list
Hi Inawab770
If the following example reflects what you expect you can get this from PowerBI (it includes Power Query)
If you need a Power BI working example please share a roaster workbook with i.e https://support.microsoft.com/en-us/office/share-onedrive-files-and-folders-9fcc2f7d-de0c-4cec-93b0-a82024800c07, Google Drive... and post the link here
Thank you very much for your help, you can find google drive link below
https://drive.google.com/drive/folders/1CCTq2BTr7xDCB5tZKcVNBbzxzSQekEJB?usp=sharing
once again thank you for your help
- LorenzoJul 03, 2022Silver Contributor
Hi Inawab770
PowerBI Query code:
let Source = Excel.Workbook( File.Contents("D:\Lorenzo\Downloads\Staff Roster.xlsx"), null, true ), SheetOne = Source{[Item="Sheet1", Kind="Sheet"]}[Data], PromotedHeaders = Table.PromoteHeaders(SheetOne, [PromoteAllScalars=true]), ColumnNames = Table.ColumnNames(PromotedHeaders), RequiredColumns = Table.SelectColumns(PromotedHeaders, List.FirstN(ColumnNames, List.PositionOf(ColumnNames, "CITY")) ), UnpivotedOtherColumns = Table.UnpivotOtherColumns(RequiredColumns, {"Name"}, "Date", "Shift"), DatesAsNumbers = Table.TransformColumns(UnpivotedOtherColumns, {"Date", Number.From, Int64.Type} ), ChangedTypes = Table.TransformColumnTypes(DatesAsNumbers, {{"Name", type text}, {"Date", type date}, {"Shift", type text}} ) in ChangedTypes
NB: Update line File.Contents("D:\Lorenzo\Downloads\Staff Roster.xlsx") with your path to the file
Assumptions made:
- Roster is on sheet named Sheet1 as in the file you shared
- Column [Name] is always the 1st column as in the file you shared
- Column [CITY] is always the 1st column after the Date columns as in the file you sharedThe position of the latter is used to determine the number of Date columns (not all months have 31 days)
Attached file is zipped as .pbix isn't allowed