Forum Discussion

syasmin25's avatar
syasmin25
Helper V
6 years ago
Solved

Importing multiple files from Sharepoint

Hello, 

I had a simple question. I am trying to import multiple Excel files from Sharepoint. They are all located in the same folder. I know how to combine, however I do not want to do that as the tables needs to be cleaned up a bit individually. I know how to get one file, however, I was wondering if there is anyway by which I can get multiple of them together? Please let me know.

  • Hi syasmin25 ,

     

    We can create three queries, make different clean steps on each query,  such as

    Query_A:

    let
        Source = SharePoint.Files("URL", [ApiVersion = 15]),
        File_A = Source{[Name="File_A",#"Folder Path"="Folder"]}[Content],
        File_A_Content = Excel.Workbook(File_A),
        CleanStep1 = AAAAA,
        CleanStep2 = BBBBB
    in
        CleanStep2

     

    Query_B:

    let
        Source = SharePoint.Files("URL", [ApiVersion = 15]),
        File_B = Source{[Name="File_B",#"Folder Path"="Folder"]}[Content],
        File_B_Content = Excel.Workbook(File_B),
        CleanStep1 = CCCCC,
        CleanStep2 = DDDDD
    in
        CleanStep2

     

    Quer_C:

    let
        Source = SharePoint.Files("URL", [ApiVersion = 15]),
        File_C = Source{[Name="File_C",#"Folder Path"="Folder"]}[Content],
        File_C_Content = Excel.Workbook(File_C),
        CleanStep1 = EEEEE,
        CleanStep2 = FFFFF
    in
        CleanStep2

     

    Then we can create another query to combine them

    let
      Source = Table.Combine({Query_A,Query_B,Query_C})
    in
      Source

     

    Or we can also write all  of them in single query, such as following:

    let
      Table_A = let
                  Source = SharePoint.Files("URL", [ApiVersion = 15]),
                  File_A = Source{[Name="File_A",#"Folder Path"="Folder"]}[Content],
                  File_A_Content = Excel.Workbook(File_A),
                  CleanStep1 = AAAAA,
                  CleanStep2 = BBBBB
                in
                  CleanStep2,
      Table_B = let
                  Source = SharePoint.Files("URL", [ApiVersion = 15]),
                  File_B = Source{[Name="File_B",#"Folder Path"="Folder"]}[Content],
                  File_B_Content = Excel.Workbook(File_B),
                  CleanStep1 = CCCCC,
                  CleanStep2 = DDDDDD
                in
                  CleanStep2,
      Table_C = let
                  Source = SharePoint.Files("URL", [ApiVersion = 15]),
                  File_C = Source{[Name="File_C",#"Folder Path"="Folder"]}[Content],
                  File_C_Content = Excel.Workbook(File_C),
                  CleanStep1 = EEEEE,
                  CleanStep2 = FFFFF
                in
                  CleanStep2,
      Combine_Table = Table.Combine({Table_A,Table_B,Table_C})
    in
      Combine_Table

     

    If you have any other questions, please kindly ask here and we will try to resolve it.


    Best regards,

     

1 Reply

  • v-lid-msft's avatar
    v-lid-msft
    Community Support

    Hi syasmin25 ,

     

    We can create three queries, make different clean steps on each query,  such as

    Query_A:

    let
        Source = SharePoint.Files("URL", [ApiVersion = 15]),
        File_A = Source{[Name="File_A",#"Folder Path"="Folder"]}[Content],
        File_A_Content = Excel.Workbook(File_A),
        CleanStep1 = AAAAA,
        CleanStep2 = BBBBB
    in
        CleanStep2

     

    Query_B:

    let
        Source = SharePoint.Files("URL", [ApiVersion = 15]),
        File_B = Source{[Name="File_B",#"Folder Path"="Folder"]}[Content],
        File_B_Content = Excel.Workbook(File_B),
        CleanStep1 = CCCCC,
        CleanStep2 = DDDDD
    in
        CleanStep2

     

    Quer_C:

    let
        Source = SharePoint.Files("URL", [ApiVersion = 15]),
        File_C = Source{[Name="File_C",#"Folder Path"="Folder"]}[Content],
        File_C_Content = Excel.Workbook(File_C),
        CleanStep1 = EEEEE,
        CleanStep2 = FFFFF
    in
        CleanStep2

     

    Then we can create another query to combine them

    let
      Source = Table.Combine({Query_A,Query_B,Query_C})
    in
      Source

     

    Or we can also write all  of them in single query, such as following:

    let
      Table_A = let
                  Source = SharePoint.Files("URL", [ApiVersion = 15]),
                  File_A = Source{[Name="File_A",#"Folder Path"="Folder"]}[Content],
                  File_A_Content = Excel.Workbook(File_A),
                  CleanStep1 = AAAAA,
                  CleanStep2 = BBBBB
                in
                  CleanStep2,
      Table_B = let
                  Source = SharePoint.Files("URL", [ApiVersion = 15]),
                  File_B = Source{[Name="File_B",#"Folder Path"="Folder"]}[Content],
                  File_B_Content = Excel.Workbook(File_B),
                  CleanStep1 = CCCCC,
                  CleanStep2 = DDDDDD
                in
                  CleanStep2,
      Table_C = let
                  Source = SharePoint.Files("URL", [ApiVersion = 15]),
                  File_C = Source{[Name="File_C",#"Folder Path"="Folder"]}[Content],
                  File_C_Content = Excel.Workbook(File_C),
                  CleanStep1 = EEEEE,
                  CleanStep2 = FFFFF
                in
                  CleanStep2,
      Combine_Table = Table.Combine({Table_A,Table_B,Table_C})
    in
      Combine_Table

     

    If you have any other questions, please kindly ask here and we will try to resolve it.


    Best regards,