从多个网站中的多个 SharePoint 库获取数据

Get data from multiples SharePoint library's in multiple sites

提问人:user3704742 提问时间:11/15/2023 最后编辑:Sam Nseiruser3704742 更新时间:11/15/2023 访问量:33

问:

我想从位于不同 SharePoint 网站集中的多个 SharePoint 库中提取信息。

同名的所有库都具有相同的结构。我收到一个错误,无法将值“Library1”转换为类型 List。

我正在使用以下脚本:

let
    sitesEBibliotecas = {
        {"https://Site1", {"Library1", "Library2"}},
        {"https://Site2", {"Library1", "Library2"}}
    },

    tabelasDeBibliotecas = List.Combine(
        List.Transform(
            sitesEBibliotecas,
            each List.Combine(
                List.Transform(
                    _{1},
                    each let
                        biblioteca = _,
                        Origem = SharePoint.Tables(_{0} & "/" & biblioteca, [ApiVersion = 15]),
                        lista = Origem{[Id=biblioteca]}[Items]
                    in
                        lista
                )
            )
        )
    ),
    tabelasDeBibliotecas1 = tabelasDeBibliotecas{0}
in
    tabelasDeBibliotecas1
SharePoint PowerBI PowerQuery

评论

0赞 Sam Nseir 11/15/2023
请将代码粘贴为文本,而不是图像。编辑您的问题以包含代码,以便其他人可以复制粘贴等...

答:

0赞 horseyride 11/15/2023 #1

如果你坚持这个列表结构,那么你需要类似于下面的东西

let
sitesEBibliotecas = {
    {"https://Site1", {"Library1", "Library2"}},
    {"https://Site2", {"Library1", "Library2"}}
},
hitlist= Table.FromList(List.Combine(List.Transform(sitesEBibliotecas, each  let a=_ in List.Transform (a{1}, each a{0}& "/" &_ )))),
#"Added Custom" = Table.AddColumn(hitlist, "Output", each SharePoint.Tables([Column1]))
in #"Added Custom"

enter image description here

0赞 Sam Nseir 11/15/2023 #2

此位导致了问题。更新了查询以将站点名称存储在变量中。SharePoint.Tables(_{0}

let
  sitesEBibliotecas = {
    {"https://Site1", {"Library1", "Library2"}},
    {"https://Site2", {"Library1", "Library2"}}
  },

  tabelasDeBibliotecas = List.Combine(
    List.Transform(
        sitesEBibliotecas,
        each let
          site = _{0},
          libraries = _{1},
          combined =  List.Combine(
            List.Transform(
              libraries,
              each let
                biblioteca = _,
                Origem = SharePoint.Tables(site & "/" & biblioteca, [ApiVersion = 15]),
                lista = Origem{[Id=biblioteca]}[Items]
              in
                lista
            )
          )
        in combined
    )
  ),
  tabelasDeBibliotecas1 = tabelasDeBibliotecas{0}
in
  tabelasDeBibliotecas1

评论

0赞 Sam Nseir 11/23/2023
这回答了你的问题吗?