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
v-juanli-msft
6 years agoCommunity Support
Hi cricks
It may be possible.
We need to know that:
is the screenshot the original data in excel or expected format after transforming with Power BI?
is there "date" column in your original data?
are the "date" for each group same?
Best Regards
Maggie