我在 A 和 B 下面有两张表。我想通过复制表 A 中的行,填充表 B 的日期列中缺少的日期,将表 A 转换为表 C,这将导致每个 id 的行数相等。
表A
id | 日期 | 金额 |
---|---|---|
1 | 2010年1月9日 | 4 |
1 | 2011年1月3日 | 3 |
2 | 2011/01/12 | 3 |
3 | 2011年1月3日 | 1 |
3 | 2011/01/06 | 1 |
3 | 2011年1月9日 | 1 |
表B
日期 |
---|
2010年1月9日 |
2010年1月12日 |
2011年1月3日 |
2011/01/06 |
2011年1月9日 |
表C
id | 日期 | 金额 |
---|---|---|
1 | 2010年1月9日 | 4 |
1 | 2010年1月12日 | 空 |
1 | 2011年1月3日 | 3 |
1 | 2011/01/06 | 空 |
1 | 2011年1月9日 | 空 |
2 | 2010年1月9日 | 空 |
2 | 2010年1月12日 | 空 |
2 | 2011年1月3日 | 3 |
2 | 2011/01/06 | 空 |
2 | 2011年1月9日 | 空 |
3 | 2010年1月9日 | 空 |
3 | 2010年1月12日 | 空 |
3 | 2011年1月3日 | 1 |
3 | 2011/01/06 | 1 |
3 | 2011年1月9日 | 1 |
尝试
let Source = Table.Distinct(Table.SelectColumns(TableA,{"id"})),
#"Added Custom" = Table.AddColumn(Source, "Dates", each Table.Distinct(TableA & TableB, {"Dates"})[Dates]),
#"Expanded Dates" = Table.ExpandListColumn(#"Added Custom", "Dates"),
#"Merged Queries" = Table.NestedJoin(#"Expanded Dates", {"id", "Dates"}, TableA, {"id", "Dates"}, "TableA", JoinKind.LeftOuter),
#"Expanded TableA" = Table.ExpandTableColumn(#"Merged Queries", "TableA", {"Amount"}, {"Amount"})
in #"Expanded TableA"