在电源查询中,如果我们从sql数据库获取数据," Value"和"表"如果数据库中存在关系,则会自动创建列。
AFAIK"表"和"价值"分别表示一对多和多对一关系。
我的问题是我们的数据库中没有任何关系。因此PowerQuery无法自动生成这些列。 如果我知道主题表之间的关系,我该如何手动添加这些列?
我找到了返回Table对象的Table.NestedJoin函数(但性能很低,即使数据库中存在关系。)
但我找不到任何返回Value对象的函数(另一个表的记录)。
可能存在缺陷的其他解决方案;
提前致谢...
答案 0 :(得分:0)
Just today I had quite same issue with performance, but finally solved it. In my solution I work with views, but need to filter records coming.
When I use such a code:
let
filter1 = 2016,
filter2 = "SomeText",
tbl = Sql.Database("MyServer","MyDB"){Schema="dbo",Item="MyTableOrView"}[Data],
filteredTable = Table.SelectRows(tbl, each ([field1] = filter1) and ([field2] = filter2))
in
filteredTable
it works slow. But if I try NestedJoin - it performs much better.
let
Source = Table.FromColumns({{2016}, {"SomeText"}}, "filter1", "filter2"),
tbl = Sql.Database("MyServer","MyDB"){Schema="dbo",Item="MyTableOrView"}[Data],
filteredTable = Table.NestedJoin(tbl, {"field1", "field2"}, Source, {"filter1", "filter2"}, "NewColumn", JoinKind.Inner)
in
filteredTable
However, I noticed that even fastest design I got works slower than just a query that returns all ~~1300 rows from the view.
I have no SQL Profiler to track down what is exactly sent to the server, but it seems to me that query folding work when you use inner joins.
Try following: make 2 queries to 2 tables (no other actions!) and inner join them, then see if it works faster.