简体   繁体   English

在 Power BI 中合并两个表

[英]Combine two tables in Power BI

I have:我有:

Table1:表格1:

|-----|-----------|---------|
| ID  | Last Name | Country |
| 200 | Abc       |Germany  |
| 444 | JHk       | Norway  |
|-----|-----------|---------|

Table 2:表 2:

|-------|----------|
| Month | Year     |
| 10    | 2020     |
| 11    | 2020     |
|-------|----------|

I want to have just 1 table like this:我只想有一张这样的桌子:

Table 3:表3:

|-----|-----------|---------|-------|------|
| ID  | Last name | Country | Month | Year |
| 200 | Abc       | Germany | 10    | 2020 |
| 444 | JHk       | Norway  | 10    | 2020 |
| 200 | Abc       | Germany | 11    | 2020 |
| 444 | JHk       | Norway  | 11    | 2020 |
|-----|-----------|---------|-------|------|

In SQL it would be:在 SQL 中,它将是:

SELECT * FROM Table1, Table2; SELECT * FROM Table1, Table2;

Go to Power Query Editor and follow these below steps-转到Power Query 编辑器并按照以下步骤操作 -

Step 1: Create a Custom Column in Table1 with a fixed value 1 as below-第 1 步:Table1 中创建一个自定义列,其固定值为 1,如下所示-

在此处输入图片说明

Step 2: Create a Custom Column in Table2 with a fixed value 1 as shown above.第二步:Table2中创建一个自定义列,固定值为1,如上图。

Step 3: Merge Table2 in Table1 using new column as shown below-第 3 步:使用新列合并Table1 中的Table2 ,如下所示 -

在此处输入图片说明

Step 4: Expand column and keep only month and year column and your output will be as below-第 4 步:展开列并仅保留月和年列,您的输出将如下所示-

在此处输入图片说明

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

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