Forum Discussion

MoussaBAK's avatar
MoussaBAK
Frequent Visitor
4 years ago
Solved

Filling up and down from a specific column

Hello to all, I'm new to PowerQuery and I'm trying to reprocess a database file. This file has the particularity to have the data stacked on 2 columns as follows: The information contained in...
  • v-jingzhang's avatar
    3 years ago

    Hi MoussaBAK 

     

    Here is my solution. The excel file is attached at bottom. 

    let
        Source = Excel.CurrentWorkbook(){[Name="Tableau1"]}[Content],
        #"Type modifié" = Table.TransformColumnTypes(Source,{{"Colonne1", type text}, {"Colonne2", type text}}),
        #"Colonnes renommées" = Table.RenameColumns(#"Type modifié",{{"Colonne1", "Rubrique"}, {"Colonne2", "Informations"}}),
        #"Index ajouté" = Table.AddIndexColumn(#"Colonnes renommées", "Index", 1, 1, Int64.Type),
        #"Colonne dynamique" = Table.Pivot(#"Index ajouté", List.Distinct(#"Index ajouté"[Rubrique]), "Rubrique", "Informations"),
        // get the list of table column names
        column_names = Table.ColumnNames(#"Colonne dynamique"),
        // get the position index of "Matricule " in the name list
        position_of_Matricule = List.PositionOf(column_names, "Matricule "),
        #"Rempli vers le bas" = Table.FillDown(#"Colonne dynamique",List.Range(column_names, 0, position_of_Matricule)),
        #"Rempli vers le haut" = Table.FillUp(#"Rempli vers le bas",List.Range(column_names, position_of_Matricule + 1, List.Count(column_names) - 1 - position_of_Matricule)),
        #"Lignes filtrées" = Table.SelectRows(#"Rempli vers le haut", each ([#"Matricule "] <> null))
    in
        #"Lignes filtrées"

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.