Forum Discussion
concatenate Query results row values to create columns
- 4 years ago
I ended up solving my problem. In the end, I got rid of the additional query Admlistcol.
I modified my code as follows to accomplish what I wanted:
let
Source = #"Contracts Terms",
#"Lignes filtrées" = Table.SelectRows(Source, each ([Catégorie] = "Administration")),
#"Colonnes supprimées" = Table.RemoveColumns(#"Lignes filtrées",{"Catégorie"}),
#"Type modifié" = Table.TransformColumnTypes(#"Colonnes supprimées",{{"Plan", type text}}),
#"Lignes groupées" = Table.Group(#"Type modifié", {"Department", "Sous-catégorie"}, {{"Rows", each _, type table [Department=nullable text, #"Sous-catégorie"=nullable text, Plan=nullable text]}}),
Indexed = Table.TransformColumns(#"Lignes groupées", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}),
#"Rows développé" = Table.ExpandTableColumn(Indexed, "Rows", {"Plan", "GroupIndex"}, {"Plan", "GroupIndex"}),
#"Lignes triées" = Table.Sort(#"Rows développé",{{"Sous-catégorie", Order.Ascending}}),
#"Colonne dynamique1" = Table.Pivot(Table.TransformColumnTypes(#"Lignes triées", {{"GroupIndex", type text}}, "fr-CA"), List.Distinct(Table.TransformColumnTypes(#"Lignes triées", {{"GroupIndex", type text}}, "fr-CA")[GroupIndex]), "GroupIndex", "Plan"),
#"Colonnes fusionnées" = Table.CombineColumns(#"Colonne dynamique1",List.RemoveFirstN(Table.ColumnNames(#"Colonne dynamique1"),2),Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Plan"),
#"Colonne dynamique" = Table.Pivot(#"Colonnes fusionnées", List.Distinct(#"Colonnes fusionnées"[Department]), "Department", "Plan")
in
#"Colonne dynamique"
Yes, that is my problem right now.
I have this one query to get to my list that I want to bring into the step.
Admlistcol
let
Source = #"Contracts Terms",
#"Lignes filtrées" = Table.SelectRows(Source, each ([Catégorie] = "Administration")),
#"Colonnes supprimées" = Table.RemoveColumns(#"Lignes filtrées",{"Catégorie", "Plan"}),
#"Lignes groupées" = Table.Group(#"Colonnes supprimées", {"Department", "Sous-catégorie"}, {{"Rows", each _, type table [Department=nullable text, #"Sous-catégorie"=nullable text]}}),
Indexed = Table.TransformColumns(#"Lignes groupées", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}),
#"Rows développé" = Table.ExpandTableColumn(Indexed, "Rows", {"Plan", "GroupIndex"}, {"Plan", "GroupIndex"}),
#"Colonnes supprimées1" = Table.RemoveColumns(#"Rows développé",{"Department", "Sous-catégorie", "Plan"}),
#"Doublons supprimés" = Table.Distinct(#"Colonnes supprimées1"),
#"Préfixe ajouté" = Table.TransformColumns(#"Doublons supprimés", {{"GroupIndex", each """" & Text.From(_, "fr-CA"), type text}}),
#"Suffixe ajouté" = Table.TransformColumns(#"Préfixe ajouté", {{"GroupIndex", each _ & """", type text}}),
#"Personnalisée ajoutée" = Table.AddColumn(#"Suffixe ajouté", "lst", each 1),
#"Colonnes renommées" = Table.RenameColumns(#"Personnalisée ajoutée",{{"GroupIndex", "col"}}),
#"Lignes groupées1" = Table.Group(#"Colonnes renommées", {"lst"}, {{"lst.1", each _, type table [col=text, lst=number]}}),
#"Personnalisée ajoutée1" = Table.AddColumn(#"Lignes groupées1", "col", each [lst.1][col]),
#"Colonnes supprimées2" = Table.RemoveColumns(#"Personnalisée ajoutée1",{"lst", "lst.1"}),
#"Valeurs extraites" = Table.TransformColumns(#"Colonnes supprimées2", {"col", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
col = #"Valeurs extraites"{0}[col]
in
col
The results: "1","2","3","4","5","6","7"
I'm trying to reference Admlistcol in my other query get that list to generate.
let
Source = #"Contracts Terms",
#"Lignes filtrées" = Table.SelectRows(Source, each ([Catégorie] = "Administration")),
#"Colonnes supprimées" = Table.RemoveColumns(#"Lignes filtrées",{"Catégorie"}),
#"Type modifié" = Table.TransformColumnTypes(#"Colonnes supprimées",{{"Plan", type text}}),
#"Lignes groupées" = Table.Group(#"Type modifié", {"Department", "Sous-catégorie"}, {{"Rows", each _, type table [Department=nullable text, #"Sous-catégorie"=nullable text, Plan=nullable text]}}),
Indexed = Table.TransformColumns(#"Lignes groupées", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}),
#"Rows développé" = Table.ExpandTableColumn(Indexed, "Rows", {"Plan", "GroupIndex"}, {"Plan", "GroupIndex"}),
#"Lignes triées" = Table.Sort(#"Rows développé",{{"Sous-catégorie", Order.Ascending}}),
#"Colonne dynamique1" = Table.Pivot(Table.TransformColumnTypes(#"Lignes triées", {{"GroupIndex", type text}}, "fr-CA"), List.Distinct(Table.TransformColumnTypes(#"Lignes triées", {{"GroupIndex", type text}}, "fr-CA")[GroupIndex]), "GroupIndex", "Plan"),
#"Colonnes fusionnées" = Table.CombineColumns(#"Colonne dynamique1",Admlistcol,Combiner.CombineTextByDelimiter("
", QuoteStyle.None),"Plan"),
#"Colonne dynamique" = Table.Pivot(#"Colonnes fusionnées", List.Distinct(#"Colonnes fusionnées"[Department]), "Department", "Plan")
in
#"Colonne dynamique"
Hi jean004,
Good to hear that you were able to find a way to resolve the problem.
I think it could also be resolved by applying Text.Split to a referece to Admlistcol in #"Colonnes fusionnées" step to make it a list:
#"Colonnes fusionnées" = Table.CombineColumns(#"Colonne dynamique1",Text.Split(Admlistcol, ","),Combiner.CombineTextByDelimiter("
", QuoteStyle.None),"Plan"),Kind regards,
John