Forum Discussion
Anonymous
4 years agoNot applicable
Combine and filter multiple Date/Time and data columns
This may or may not be compliated but I am new to power query and am still learning. I have a set of data that is a combination of 12 individual equiptment data columns, but each equiptment data has ...
KT_Bsmart2gethe
Impactful Individual
4 years agoHI Anonymous,
Is below outcome what you're looking for?
I need to re-write part of the code to make it dynamic if this is what you are after.
Code:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
//Only keep two Date/Time Columns
KeepDateTime = Table.RemoveColumns(
Source,
List.RemoveFirstN(
List.Select(
Table.ColumnNames(Source),
each
Text.Contains(_,"Time")
),
2
)
),
//Renamed the two Date/Time columns to Date & Time
RenamedDateTime = Table.RenameColumns(
KeepDateTime,
List.Transform(
List.Select(
Table.ColumnNames(KeepDateTime),
each
Text.Contains(_,"Time")
),
each
{_, if Text.StartsWith(_,"Part 2")
then "Time"
else "Date"
}
)
),
//Reordered columns to Date, Time, Part 1, 2 3 ....
ReorderedCol = Table.ReorderColumns(
RenamedDateTime,
{"Date", "Time"} & List.Select(
Table.ColumnNames(RenamedDateTime),
each
_<>"Time" and _<>"Date"
)
),
//Changed Data Type Date & Time
#"Changed Type" = Table.TransformColumnTypes(
ReorderedCol,
{
{"Date", type date},
{"Time", type time}
}
),
//Demote headers before transpose
DemotedHdrs = Table.DemoteHeaders(#"Changed Type"),
//Transpose Table
TransposedTbl = Table.Transpose(DemotedHdrs),
//Add label - "Equipment x" (required to rewrite this part to make it dynamics label)
CombineTbls = Table.Combine({#table({"Column1"},{{"Equipment 1:"}}),TransposedTbl})
in
CombineTbls
Regards
KT
Anonymous
4 years agoNot applicable
This does look almost exactly what I need. If it is transposed that would be it.