Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Daniel_JD
Frequent Visitor

How to do unpivot multiple sheets of Attendance

Hi all,

I have attendance data in Excel in the following way.

Sheets: January 2023, February 2023, etc..

In each sheet, 

IDName2-Oct-233-Oct-234-Oct-235-Oct-236-Oct-23
  MondayTuesdayWednesdayThursdayFriday
1BirdiePLPL6:00 AM - 3:00 PM6:00 AM - 3:00 PM6:00 AM - 3:00 PM
2AbbiPL6:00 AM - 3:00 PM6:00 AM - 3:00 PM1:30 PM - 10:30 PM6:00 AM - 3:00 PM
3Carina6:00 AM - 3:00 PM6:00 AM - 3:00 PM6:00 AM - 3:00 PM6:00 AM - 3:00 PM6:00 AM - 3:00 PM

 

I required the format,

Emp IDNameDateShift
1Birdie2-Oct-23PL
1Birdie3-Oct-23PL
1Birdie4-Oct-236:00 AM - 3:00 PM
1Birdie5-Oct-236:00 AM - 3:00 PM
1Birdie6-Oct-236:00 AM - 3:00 PM
2Abbi2-Oct-23PL
2Abbi3-Oct-236:00 AM - 3:00 PM
2Abbi4-Oct-236:00 AM - 3:00 PM
2Abbi5-Oct-231:30 PM - 10:30 PM
2Abbi6-Oct-236:00 AM - 3:00 PM
3Carina2-Oct-236:00 AM - 3:00 PM
3Carina3-Oct-236:00 AM - 3:00 PM
3Carina4-Oct-236:00 AM - 3:00 PM
3Carina5-Oct-236:00 AM - 3:00 PM
3Carina6-Oct-236:00 AM - 3:00 PM

 

Kindly help me to figure out the solution for the power query in Power BI.

Thanks in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Daniel_JD 

You can refer to the follwing solution.

1.You can ceeate a blank query , then put the following code to advanced editor in power query

(A as table)=>
let
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(A, {"ID", "Name"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Date"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Date", type date}})
in
    #"Changed Type1"

Set it as a function.

2.Then import other tables and use the funtion.

vxinruzhumsft_0-1696830574451.png

 

You can refer to the following video and attachments.

Bing Videos

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

11 REPLIES 11
Anonymous
Not applicable

Hi @Daniel_JD 

You can refer to the follwing solution.

1.You can ceeate a blank query , then put the following code to advanced editor in power query

(A as table)=>
let
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(A, {"ID", "Name"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Date"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Date", type date}})
in
    #"Changed Type1"

Set it as a function.

2.Then import other tables and use the funtion.

vxinruzhumsft_0-1696830574451.png

 

You can refer to the following video and attachments.

Bing Videos

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks, @Anonymous, this is helpful. One quick question do I need to refer each month manually?

 

Anonymous
Not applicable

Hi @Daniel_JD 

You need to import the tables, and then just put the table to the function. then it will be transformed automically.

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

If the files are separate as shown in the video we can refer to the table. but mine has a single file with multiple sheets. guild to fix it!

Anonymous
Not applicable

Hi @Daniel_JD 

You can import one sheet first, then tranform it and set it as the function, then import other sheets in the file, and use the function.

 

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

mlsx4
Memorable Member
Memorable Member

Hi @Daniel_JD 

 

  1. First of all, you should append all your sheets in a unique file: Follow this tutorial and instead of removing empty rows (you may not have), filter by ID <>null (to remove the rows that have Monday, Tuesday...) https://www.youtube.com/watch?v=gQo5coD9c4M
  2. Once you have combined all files: select the column ID and Name, go to Transform tab> Unpivot other column

mlsx4_1-1696587216197.png

 

Thanks @mlsx4,

I tried the same, and when I combined the sheets the dates were on the first row, so I can't make it as the header. (if I did the dates on the next sheet will be ignored).

 

On the video, they have the dates on the first column but in my case, it is in the first row in all sheets.

Further suggestions are welcome..

Hi @Daniel_JD 

 

You're right. Probably you can follow the steps in this solution to combine: https://community.fabric.microsoft.com/t5/Power-Query/Automatically-import-multiple-Excel-files-by-M...

 

I mean, you apply first transformations to each file and then combine

I have checked that, which will be applicable when the files are separated mine is a single file with a different sheet. 

Please correct me if I did not understand that solution properly!

You're right @Daniel_JD 

 

I don't have any more ideas (apart from doing manually). Probably Yolo Zhu's solution will work!!

Thanks @mlsx4.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.