Forum Discussion
Change Sequenced data to Columns
I am so sorry. Here is the English version:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjc3V9JRcgwPBpKGSrE60UoW5kZAtruzG1zE0twYpKaqtCgVLmZoYmAA5PgXJSbnIEQhpplDNBshGeeSWJLonFgEF4UYGVKUWQAXgpoYHBkBF4IYBxExRjINbqsxsvvAfjBGNss3OAQuBDEL4jITJLPc/INC4EIQkyDaTJBN8nN1hAjFAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Platform = _t, #"Platform Sequence" = _t]),
#"Change Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Platform", type text}, {"Platform Sequence", type text}}),
AddColumnName = Table.AddColumn(#"Change Type", "ColumnName", each "Platform " & [Platform Sequence]),
DeleteColumns = Table.RemoveColumns(AddColumnName,{"Platform Sequence"}),
Table.Pivot = Table.Pivot(DeleteColumns, List.Distinct(DeleteColumns[ColumnName]), "ColumnName", "Platform")
in
Table.PivotThank you! This syntax is almost exactly what I need. How would I incorporate the change of the source to a sql. database and schema? Like the below?
Source = Sql.Database("SERVERNAME", "DATABASE NAME"),
Roadmap_AppTargetPlatform = Source{[Schema="Roadmap",Item="AppTargetPlatform"]}[Data],
- bolfri3 years agoSolution Sage
let Source = Sql.Database("SERVERNAME", "DATABASE NAME"), Roadmap_AppTargetPlatform = Source{[Schema="Roadmap",Item="AppTargetPlatform"]}[Data], #"Change Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Platform", type text}, {"Platform Sequence", type text}}), AddColumnName = Table.AddColumn(#"Change Type", "ColumnName", each "Platform " & [Platform Sequence]), DeleteColumns = Table.RemoveColumns(AddColumnName,{"Platform Sequence"}), Table.Pivot = Table.Pivot(DeleteColumns, List.Distinct(DeleteColumns[ColumnName]), "ColumnName", "Platform") in Table.Pivot- bblackwell33 years agoHelper II
I created a new table using the above syntax and altered it to include my actual column names into the syntax below
let
Source = Sql.Database("LOUSQLWTS711", "AppJourneyTrackingDB_Dev"),
Roadmap_AppTargetPlatform = Source{[Schema="Roadmap",Item="AppTargetPlatform"]}[Data],
#"Change Type" = Table.TransformColumnTypes(Source,{{"AppId", type text}, {"PlatformName", type text}, {"PlatformSequence", type text}}),
AddColumnName = Table.AddColumn(#"Change Type", "ColumnName", each "PlatformName " & [PlatformSequence]),
DeleteColumns = Table.RemoveColumns(AddColumnName,{"PlatformSequence"}),
Table.Pivot = Table.Pivot(DeleteColumns, List.Distinct(DeleteColumns[ColumnName]), "ColumnName", "PlatformName")
in
Table.PivotHowever, I get an error?
- bolfri3 years agoSolution Sage
It seems that in your table there is no AppId column. 🙂