Power Query - Change column to row if columns match - Grouping

Jessica553

New Member
Joined
Nov 21, 2021
Messages
24
Office Version
  1. 2010
Platform
  1. Windows
Hi All. I am trying to create a spreadsheet which takes employee swipe times onto a site and gives how many hours they have worked. The format I have gotten it to gives me their name, date and entry on one row and then name date and exit on the second. But how can I combine these into a single row so that I can subtract the times and get hours worked in between?

IE in the below I want one row for Bob Smith for the 9th of October to show entry and exit times (Then I'll add a formula to subtract hours). Then the next row would be Bob Smith for the 4th of September, etc.

Thank you for any help! I am learning power query slowly as I go but wasn't having much luck on google!

DateTimeEnter/ExitBadge IDSurnameFirst Name
9/10/2023​
7:01:55 AM​
CUR-MOF-Turnstile 2-Entry
12345​
SmithBob
9/10/2023​
4:10:15 PM​
CUR-MOF-Turnstile 2-Exit
12345​
SmithBob
4/09/2023​
7:04:48 AM​
CUR-MOF-Turnstile 3-Entry
12345​
SmithBob
4/09/2023​
4:09:53 PM​
CUR-MOF-Turnstile 3-Exit
12345​
SmithBob
5/09/2023​
7:04:31 AM​
CUR-MOF-Turnstile 4-Entry
12347​
WillisBruce
5/09/2023​
7:05:13 AM​
CUR-MOF-Turnstile 4-Entry
12347​
WillisBruce
5/09/2023​
2:57:14 PM​
CUR-MOF-Turnstile 6-Exit
12348​
HanksTom
5/09/2023​
4:10:05 PM​
CUR-MOF-Turnstile 3-Exit
12348​
HanksTom
7/09/2023​
7:04:25 AM​
CUR-MOF-Turnstile 6-Entry
12349​
ChaplinCharlie
7/09/2023​
4:09:57 PM​
CUR-MOF-Turnstile 4-Exit
12349​
ChaplinCharlie
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I'm looking at your data and would you show us what your expected results should look like. I don't know how you wish to handle Bruce Willis who entered twice but did not exit and how do you wish to handle Tom Hanks that left twice but never entered. Need a better understanding of what you want it to look like.
 
Upvote 0
I'm looking at your data and would you show us what your expected results should look like. I don't know how you wish to handle Bruce Willis who entered twice but did not exit and how do you wish to handle Tom Hanks that left twice but never entered. Need a better understanding of what you want it to look like.
Thank you alansidman, you've highlighted a few of the issues that have come up for me since I posted the example. I have people entering but not exiting and people entering one day and exiting the next day on nightshift so I don't know how I begin trying to solve that issue. But below is ideally what that would look like. Exit Time and turnstyle on the same row as the entry.
I'm thinking it might have to look for each instance of entry then pick up the following exit and return error if not before another entry but I don't know if that's possible or if there is a much simpler solution.
DateTimeEnter/ExitBadge IDSurnameFirst NameExit TimeExit Turnstyle
9/10/20237:01:55 AMCUR-MOF-Turnstile 2-Entry12345SmithBob4:10:15 PMCUR-MOF-Turnstile 2-Exit
9/10/20234:10:15 PMCUR-MOF-Turnstile 2-Exit12345SmithBob
4/09/20237:04:48 AMCUR-MOF-Turnstile 3-Entry12345SmithBob4:09:53 PMCUR-MOF-Turnstile 3-Exit
4/09/20234:09:53 PMCUR-MOF-Turnstile 3-Exit12345SmithBob
5/09/20237:04:31 AMCUR-MOF-Turnstile 4-Entry12347WillisBruceERRORNo Matching Exit
5/09/20237:05:13 AMCUR-MOF-Turnstile 4-Entry12347WillisBruce
5/09/20232:57:14 PMCUR-MOF-Turnstile 6-Exit12348HanksTomERRORNo Matching Entry
5/09/20234:10:05 PMCUR-MOF-Turnstile 3-Exit12348HanksTom
7/09/20237:04:25 AMCUR-MOF-Turnstile 6-Entry12349ChaplinCharlie4:09:57 PMCUR-MOF-Turnstile 4-Exit
7/09/20234:09:57 PMCUR-MOF-Turnstile 4-Exit12349ChaplinCharlie
 
Upvote 0

Forum statistics

Threads
1,215,136
Messages
6,123,246
Members
449,093
Latest member
Vincent Khandagale

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top