Forum Discussion
CornelisV
Helper IV
1 year agoHow to expand table with assigned distinctive column
Dear all, Could you please demonstrate how to expand the tabel starting from this source: Time Valve1 Valve2 13-01-2024 13:20 0 1 13-01-2024 13:30 1 0 13-01-2024 13:40 1 0 ...
_AAndrade
Resident Rockstar
1 year agoHi CornelisV,
In my solution the initial table don't have the group column as well. You can see this in the source step. I use a step on power query to add the group column.
I did some changes on my code and put all in one query, here is the M code:
let
// Original Source
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTWNTDUNTIwMlEwNLYyMlDSUQJhQ6VYHXRJY4gESAGmpAk+SVPcxppYGeCTNMQnice1JvhcawJxLVRnLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t, Valve1 = _t, Valve2 = _t]),
ChangeType = Table.TransformColumnTypes(Source, {{"Time", type datetime}, {"Valve1", Int64.Type}, {"Valve2", Int64.Type}}),
FirstTable = Table.AddColumn(ChangeType, "Group", each 1, Int64.Type),
SecondTable = Table.AddColumn(ChangeType, "Group", each 2, Int64.Type),
FinalTable = Table.Combine({FirstTable, SecondTable})
in
FinalTable
As you can see you only need to import one time the source and the final result is what you put oin your example.
I hope this could help you.
CornelisV
Helper IV
1 year agoHi _AAndrade , thank you for your effort. This is exact what I'm looking for. I have already pasted in the Advanced Editor and understand the rule of game to implement.
Best regards, Cornelis
- _AAndrade1 year ago
Resident Rockstar
Great. As my post solved your issue, please mark my post as a solution! Kudos are welcome, too 🙂
Thanks