简体   繁体   English

结合不相关数据的新 Power BI 表

[英]new Power BI table combining unrelated data

I am trying to create a table that is a list of all possible combinations between two tables: products and companies.我正在尝试创建一个表,该表是两个表之间所有可能组合的列表:产品和公司。 I'm building a dashboard in Power BI and the data comes from SQL queries.我正在 Power BI 中构建仪表板,数据来自 SQL 查询。 I have the following list structures for the Products table and the Companies table:对于 Products 表和 Companies 表,我有以下列表结构:

输入

and my desired output for analysis is:而我想要分析的 output 是:

输出

There is nothing that relates the companies to the products, and I'm trying to get a list of all of the products for each company.没有任何东西将公司与产品联系起来,我正在尝试获取每家公司的所有产品列表。 Can I do this in Power BI?我可以在 Power BI 中执行此操作吗? If not, is it possible in SQL (there is nothing to join on)?如果没有,是否可以在 SQL 中(没有什么可以加入)? Thank you for your help!谢谢您的帮助!

You can do this with a 'hacked' join, or a cross join.您可以使用“被黑”连接或交叉连接来执行此操作。 I prefer the former from a process POV, but cannot speak to speed or efficiency.我从流程 POV 中更喜欢前者,但不能谈论速度或效率。

Using a Join ( Merge in PQ )使用联接(PQ 中的合并)

  1. Create a new column 'DummyKey' with a value of 1 on each table.在每个表上创建一个值为 1 的新列“DummyKey”。
  2. Merge both tables using your 'DummyKey' columns.使用您的“DummyKey”列合并两个表。
  3. Complete the Join process and choose the columns you want to bring through.完成加入过程并选择您想要通过的列。

Cross Joins in PowerQuery according to MS根据 MS 在 PowerQuery 中进行交叉连接

I think this 'cross join' is only technically right and does not provide future flexibility.我认为这种“交叉连接”仅在技术上是正确的,并不能提供未来的灵活性。

Both methods will get you to the same end point, and can be done in SQL or PQ.这两种方法都会让您到达相同的终点,并且可以在 SQL 或 PQ 中完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM