Forum Discussion
Change Sequenced data to Columns
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.PivotI 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.Pivot
However, I get an error?
- bolfri3 years ago
Solution Sage
It seems that in your table there is no AppId column. 🙂
- bblackwell33 years ago
Helper II
I thought the same 😄 initially. This is the table I am basing it off of and it has AppId. I also get the error when changing to ID or Id??
Should I create a blank query for the syntax or create table?
- bolfri3 years ago
Solution Sage
Crate a table from your SQL connection, then give me a code from advanced editor. I will apply rest of the steps for you.