Forum Discussion
cricks
6 years agoFrequent Visitor
Multiple date/time columns
I'm trying to work with Excel data that is grouped by date/time. There can be multiple groups, each with their own DateTime column. Each group will have a different start time and interval, and a var...
- Anonymous6 years ago
Hi all,
I did it slightly differently:
let Source = myTable, Columns = List.Buffer(List.Accumulate(Table.ColumnNames(Source), {}, (s, a)=> if Text.StartsWith(a,"DateTime") then s & {{a}} else List.RemoveLastN(s,1) & {List.Last(s) & {a}} )), Output = Table.Combine(List.Accumulate(Columns, {}, (s, a) => s & {Table.UnpivotOtherColumns(Table.RenameColumns(Table.SelectColumns(Source, a), {a{0}, "DateTime"}) , {"DateTime"}, "Attribute", "Value")})) in OutputThe code above first split the columns into groups and then unpivot and combine group-by-group.
Column groups list is buffered, but this can be removed the number of columns is quite large.
Kind regards,
John
Mariusz
6 years agoCommunity Champion
Hi cricks
Can you provide a workable data sample and expected outcome? ( You can paste a copy of an excel table in the body of the comment section )
Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.

Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.

cricks
6 years agoFrequent Visitor
Here's the input format. The start time, interval, and end time for each group of data can be different.
I've also uploaded the Excel file here.
| DateTime | Data A | DateTime | Data B | Data C | DateTime | Data E | Data F | Data G | Data H | Data I | DateTime | Data J |
| 08/26/19 09:17:39 | 46.54 | 08/26/19 09:39:21 | 51 | 57.46 | 8/26/19 0:00:00 | 7980.5 | 2133.83 | 3.07147 | 59.6037 | 2544.58 | 8/24/18 0:00:00 | 18.58 |
| 08/26/19 09:19:39 | 46.7 | 08/26/19 09:40:21 | 51.1 | 57.26 | 8/26/19 0:05:00 | 8308.8 | 2252.97 | 3.23939 | 59.8167 | 2659.07 | 8/24/18 0:01:00 | 22.61 |
| 08/26/19 09:21:39 | 46.74 | 08/26/19 09:41:21 | 56.46 | 57.7 | 8/26/19 0:10:00 | 8456.7 | 2226.57 | 3.20645 | 59.8687 | 2654.93 | 8/24/18 0:02:00 | 14.89 |
| 08/26/19 09:23:39 | 47.24 | 08/26/19 09:42:21 | 51.06 | 57.58 | 8/26/19 0:15:00 | 8429 | 2188.73 | 3.15329 | 60.129 | 2597.15 | 8/24/18 0:03:00 | 7.16 |
| 08/26/19 09:25:39 | 46.82 | 08/26/19 09:43:21 | 49.06 | 57.76 | 8/26/19 0:20:00 | 8317.7 | 2134.32 | 3.08085 | 60.0408 | 2549.02 | 8/24/18 0:04:00 | 10.20 |
| 08/26/19 09:27:39 | 47.14 | 08/26/19 09:44:21 | 52.98 | 57.52 | 8/26/19 0:25:00 | 8458.7 | 2207.58 | 3.1789 | 59.8875 | 2622.75 | 8/24/18 0:05:00 | 12.47 |
| 08/26/19 09:29:39 | 46.96 | 08/26/19 09:45:21 | 51.66 | 57.06 | 8/26/19 0:30:00 | 8252.4 | 2130.67 | 3.07218 | 59.94 | 2535.77 | 8/24/18 0:06:00 | 14.74 |
Desired output format:
| DateTime | Attribute | Value |
| 08/26/19 09:17:39 | Data A | 46.54 |
| 08/26/19 09:19:39 | Data A | 46.7 |
| 08/26/19 09:21:39 | Data A | 46.74 |
| 08/26/19 09:23:39 | Data A | 47.24 |
| 08/26/19 09:25:39 | Data A | 46.82 |
| 08/26/19 09:27:39 | Data A | 47.14 |
| 08/26/19 09:29:39 | Data A | 46.96 |
| 08/26/19 09:39:21 | Data B | 51 |
| 08/26/19 09:40:21 | Data B | 51.1 |
| 08/26/19 09:41:21 | Data B | 56.46 |
| 08/26/19 09:42:21 | Data B | 51.06 |
| 08/26/19 09:43:21 | Data B | 49.06 |
| 08/26/19 09:44:21 | Data B | 52.98 |
| 08/26/19 09:45:21 | Data B | 51.66 |
| 08/26/19 09:39:21 | Data C | 57.46 |
| 08/26/19 09:40:21 | Data C | 57.26 |
| 08/26/19 09:41:21 | Data C | 57.7 |
| 08/26/19 09:42:21 | Data C | 57.58 |
| 08/26/19 09:43:21 | Data C | 57.76 |
| 08/26/19 09:44:21 | Data C | 57.52 |
| 08/26/19 09:45:21 | Data C | 57.06 |
| 8/26/19 0:00:00 | Data E | 7980.5 |
| 8/26/19 0:05:00 | Data E | 8308.8 |
| 8/26/19 0:10:00 | Data E | 8456.7 |
| 8/26/19 0:15:00 | Data E | 8429 |
| 8/26/19 0:20:00 | Data E | 8317.7 |