SOLVED

Breaking up two brackets of dates to individual rows

Copper Contributor

Hi all

 

I pull a lot of data off a database and do a lot of work around holidays and overtime. The problem I have a lot is when you book say a week off work in one block and export the data its one single line on excel is it possible to break that data up so it shows 1 line per day if you know what I mean… I have given an example below

 

RawData

 

Date From

Date To

Info

Subt

Description

From

to

Hours

Employee Name

Employee number

14.08.2022

14.08.2022

Holiday 

Holiday

 

 

12

John Smith

12345

12.06.2022

15.06.2022

Holiday

 

Holiday

 

 

48

Bob Jones

54321

 

 

This is how I would like it to be formatted

 

Date From

Date To

Info

Subt

Description

From

to

Hours

Employee Name

SAP No

14.08.2022

14.08.2022

Holiday 

Holiday

 

 

12

John Smith

12345

12.06.2022

12.06.2022

Holiday

 

Holiday

 

 

12

Bob Jones

54321

13.06.2022

13.06.2022

Holiday

 

Holiday

 

 

12

Bob Jones54321

14.06.2022

14.06.2022

Holiday

 

Holiday

 

 

12

Bob Jones54321

15.06.2022

15.06.2022

Holiday

 

Holiday

 

 

12

Bob Jones54321

 

5 Replies

Hi @SBaldwin93 

 

With Get & Transform aka Power Query (attached):

Put your raw data in the Blue table in sheet Raw Data

Switch to sheet ExpandedDates

Right-click in the Green table > Refresh

 

@L z.  This is amazing thank you so much!!!!!!!  Just looking at it now... it seems to pick up single days off well however when there is a block booking it seems to add a day at the end and not pick up the first day, ive had a look in power quays and cant  see what needs to be changed see below as an example 

 

Raw Data

 

01.06.202201.06.2022Abs100Holiday  12John Smith12345
26.07.202229.07.2022Abs100Holiday  48John Smith12345
05.08.202205.08.2022Abs100Holiday  12John Smith12345

 

Result

01/06/202201/06/2022Abs100Holiday  12John Smith 12345
05/08/202205/08/2022Abs100Holiday  12John Smith 12345
27/07/202227/07/2022Abs100Holiday  12John Smith 12345
28/07/202228/07/2022Abs100Holiday  12John Smith 12345
29/07/202229/07/2022Abs100Holiday  12John Smith 12345
30/07/202230/07/2022Abs100Holiday  12John Smith 12345

 

 

best response confirmed by SBaldwin93 (Copper Contributor)
Solution

@SBaldwin93 

 

You're absolutely right - my bad. Fixed in attached version

Amazing works a dream thank you!!!!

@SBaldwin93 

Glad this helped and thanks for Marking solution => helps those who Search...

Attached is an alternative that does it as a single query with conditional replacement (a bit complex if you're new to PQ)

1 best response

Accepted Solutions
best response confirmed by SBaldwin93 (Copper Contributor)
Solution

@SBaldwin93 

 

You're absolutely right - my bad. Fixed in attached version

View solution in original post