Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Append several SharePoint list sources. How to do it in M?

Hello everyone!

 

I want to merge several SharePoint lists (around 100), with the same column names, but with different names and in different sites.

 

I already tried to bring all tables and then append, but would be terrible to do it in a hundred sources. Is there a easier way to get these data in a single M Code?

  • Yes you can, I wrote a blog article on this once. Basically all you have to do is something like:

     

    let

      Source = ...

      Source1 = ...

      Source2 = ...

      Final = Table.Combine({Source, Source1, Source2})

    in

      Final

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Yes you can, I wrote a blog article on this once. Basically all you have to do is something like:

     

    let

      Source = ...

      Source1 = ...

      Source2 = ...

      Final = Table.Combine({Source, Source1, Source2})

    in

      Final

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks,

       

      Is it possible to do like a For function? Because I have a list of links in SP and now I realized we have 620 SP lists and this number increases +120 yearly.

       

       

       

      let

        Source = List_of_SP_List_Links

       

      For each List_of_SP_List_Links

      do  Final = Table.Combine({Final, SharePoint.Tables(List_of_SP_List_Links)})

      next

      in

        Final

      • danextian's avatar
        danextian
        Icon for Super User rankSuper User

        Hi Anonymous ,

         

        If you have a list  of SP links, you can import that as a table and add a custom column like this one:

         = SharePoint.Tables([URL Column], [ApiVersion = 15])

        And work from t here.

    • ElizabethTachji's avatar
      ElizabethTachji
      Icon for Helper III rankHelper III

      Hi Greg,

      Thank you for code.  amazing.  How do I get a source sublist name for each row?