power查询[expression.error]无法将值null转换为类型表

发布于 2025-02-10 03:15:08 字数 2385 浏览 1 评论 0 原文

使用不同的方法解决(请参阅最后)

我试图通过使用table.combine()函数将一些查询组合为一个。

如果我明确编写每个查询的名称(例如,table.combine({#“查询1的名称”,#“查询2”}的名称),然后应用更改,一切正常。

但是,由于我想使其动态,而不是编写名称列表,因此我将函数传递给上一步中生成的表:

”

因此,在我获得此表之后,下一步是:= table.combine(preadStep [value])。请注意,值是包含表的列的名称。显然,通过这样做,包含表的表的此列将转换为包含表的列表。这可以正常工作(我可以预览结果集),直到我点击“应用更改”按钮。当我这样做时,此消息会弹出:

“

i the https:/ https:/ https:/ https:/ /community.powerbi.com/t5/desktop/we-cannot-convert-the-value-null-to-type-table/td-p/391064“ rel =“ nofollow noreferrer”> https://communnity.poperbi。 com/t5/desktop/we-cannot-convert-the-null-null-to-type-table/td-p/391064 ,,但它不起作用。我也尝试了其他方法。

更多信息:

  • Power BI桌面版本:2.106.582.0 64位(2022年6月)
  • 数据来源:组合来自单个Excel文件的现有查询。
  • 遵循的步骤以获取我通过table.combine()函数的表格列表:
    let
    Origen = #sections[Section1],
    #"Convertido en tabla" = Record.ToTable(Origen),
    #"Errores quitados" = Table.RemoveRowsWithErrors(#"Convertido en tabla", {"Value"}),
    Personalizado1 = Table.SelectRows(#"Errores quitados", each Text.StartsWith([Name], "COMPRAS Y GASTOS")),
    Personalizado2 = Table.Combine(Personalizado1[Value])
    in
    Personalizado2

我访问我拥有的所有查询(使用#Sections关键字),将其转换为表格,删除可能的错误,过滤器以获取查询i想要(从“ compras y gastos”开始的那些),然后尝试结合查询)。

另一种方法 我想做的是合并来自Excel文件的桌子,每个文件都提到一年(2019,2020,2021,2022)。但是我还希望将新纸在Excel(2023,2024 ...)上添加时进行更新。

我尝试了许多不同的方法,例如生成一个动态列表(从2019年到当前年度)...但是由于某些原因,即使代码显然是正确的,它们都无法使用。

因此,我的新方法是在未来几年中创建足够数量的Excel床单(现在是空的,但是当新的一年到来时,这些信息将在那里填写),以创建参考这些床单的查询(它们返回空表格),并将现有(但空)表格合并为2019 - 2022年的表格。这样,当表格中填写了来自2023年的数据时,查询将更新并起作用。

我实际上无法解决我遇到的原始问题是一种遗憾,但是这种方法有效。

SOLVED USING A DIFFERENT APPROACH (see at the end)

I am trying to combine some queries into one by using the Table.Combine() function.

If I explicitly write the name of each query (e. g., Table.Combine({#"Name of query 1", #"Name of query 2"})) and then apply the changes, everything works fine.

However, since I want to make it dynamic, instead of writing a list of names, I pass the function a list of tables generated in a previous step:

[ALT TEXT: screenshot of a table of two columns ("Name" and "Value"), with four records. "Name": COMPRAS Y GASTOS 2019... until COMPRAS Y GASTOS 2022. "Value": an object of type Table in each of the four cells].

So after I get this table, the next step is: = Table.Combine(PreviousStep[Value]). Note that Value is the name of the column that contains the tables. Apparently, by doing so this column of a table containing tables is converted to a list containing tables. This works fine (I can preview the resultset) until I hit that Apply changes button. When I do it, this message pops up:

[ALT TEXT & translation: Error pop-up message: "Load. Anexar1 (which is the name of the query): OLE DB or ODBC error: [Expression.Error] Cannot convert the value null to type Table"].

I had a look at these threads: https://community.powerbi.com/t5/Desktop/We-cannot-convert-the-value-null-to-type-Table/td-p/391064, https://community.powerbi.com/t5/Desktop/We-cannot-convert-the-value-null-to-type-table/m-p/346056, but it didn't work. I've tried other approaches as well.

Further information:

  • Power BI Desktop version: 2.106.582.0 64-bit (June 2022)
  • Data source: combining existing queries that come from a single Excel file.
  • Steps followed to get that list of tables that I pass the Table.Combine() function:
    let
    Origen = #sections[Section1],
    #"Convertido en tabla" = Record.ToTable(Origen),
    #"Errores quitados" = Table.RemoveRowsWithErrors(#"Convertido en tabla", {"Value"}),
    Personalizado1 = Table.SelectRows(#"Errores quitados", each Text.StartsWith([Name], "COMPRAS Y GASTOS")),
    Personalizado2 = Table.Combine(Personalizado1[Value])
    in
    Personalizado2

I access all the queries I have (with the #sections keyword), convert it to a table, remove possible errors, filter to get the queries I want (the ones starting by "COMPRAS Y GASTOS") and then try to combine the queries).

A DIFFERENT APPROACH
What I wanted to do was merge tables that came from an Excel file, each of them referring to a year (2019, 2020, 2021, 2022). But I also wanted the combined table to update when new sheets were added on Excel (2023, 2024...).

I've tried many different approaches, like generating a dynamic list (from 2019 until the current year)... but for some reason none of them worked, even though the code apparently is correct.

So my new approach has been to create a sufficient amount of Excel sheets for the coming years (that are now empty, but when the new year comes the information will be filled in there), to create the queries referring to those sheets (they return empty tables) and merging those existing (but empty) tables with the ones from 2019-2022. This way, when data from 2023 is filled in in the sheet, the query is updated and it works.

It's a shame I couldn't actually solve the original problem I had, but this approach works.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文