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 ...
Anonymous
4 years agoNot applicable
So it seems my reply has dissapeared and wont let me reply to yours KT_Bsmart2gethe but here is a sample set of data. I want it to look something like this:
equipment 1:
Date
Time
Part 1
Part 2
Part 3
Part 4
Part 5
equipment 2:
Date
Time
Part 1
Part 2
Part 3
Part 4
Part 5
equipment 3:
Date
Time
Part 1
Part 2
Part 3
Part 4
Part 5
This is copy pasted from a csv file because I don't know how to attach a file here.
Part 1 Time,Part 1 Value,Part 2 Time,Part 2 Value,Part 2 Time,Part 3 Value
5/23/2022 14:18,0.138888881,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118421048
5/23/2022 14:18,0.138888881,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118421048
5/23/2022 14:18,0.138888881,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118421048
5/23/2022 14:18,0.138522431,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118421048
5/23/2022 14:18,0.138522431,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118421048
5/23/2022 14:18,0.138522431,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118421048
5/23/2022 14:18,0.138522431,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118421048
5/23/2022 14:18,0.138522431,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118421048
5/23/2022 14:18,0.138522431,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118421048
5/23/2022 14:18,0.138522431,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118421048
5/23/2022 14:18,0.138522431,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118421048
5/23/2022 14:18,0.138522431,5/23/2022 14:18,0.315789461,5/23/2022 14:18,0.118110232
5/23/2022 14:19,0.138522431,5/23/2022 14:19,0.314960659,5/23/2022 14:19,0.118110232
5/23/2022 14:19,0.138522431,5/23/2022 14:19,0.314960659,5/23/2022 14:19,0.118110232
5/23/2022 14:19,0.138522431,5/23/2022 14:19,0.314960659,5/23/2022 14:19,0.118110232
5/23/2022 14:19,0.138157889,5/23/2022 14:19,0.314960659,5/23/2022 14:19,0.118110232
5/23/2022 14:19,0.138157889,5/23/2022 14:19,0.314960659,5/23/2022 14:19,0.118110232
5/23/2022 14:19,0.138157889,5/23/2022 14:19,0.314960659,5/23/2022 14:19,0.118110232
5/23/2022 14:19,0.138157889,5/23/2022 14:19,0.314960659,5/23/2022 14:19,0.118110232KT_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