Staff roster from table to a list

Copper Contributor

Hi everyone,

 

I have the below Staff roster 

Inawab770_0-1656590951541.png

 

Tha date at top row, the names on the first caulome, in the table the shifts for each staff member.

 

I need to make this table as a list all in caulomes:

 

Staff Name - Date - Shift

 

this is so I can take itto power BI

 

is there a way to do this automated ? a formela or a power quri ?

or can I do this in power BI??

 

thank you

 

3 Replies

Hi @Inawab770 

If the following example reflects what you expect you can get this from PowerBI (it includes Power Query)

 

_Screenshot.png

If you need a Power BI working example please share a roaster workbook with i.e OneDrive, Google Drive... and post the link here

Hi @L z.

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

Hi @Inawab770 

 

_Screenshot.png

 

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 shared

The 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