power query - 扩展新列

时间:2017-02-13 12:45:42

标签: merge powerquery

我有两个表合并然后我扩展newcolumns。问题是当我们将新数据输入新月/年时,第一个表可以有新列。结果不包括这些新月。

有没有办法在合并时管理扩展新列?

查询:

let
    Source = #"320 Odemeler",
    #"Merged Queries" = Table.NestedJoin(Source,{"HESAP NO"},#"320 Faturalar",{"HESAP NO"},"NewColumn",JoinKind.LeftOuter),
    #"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries", "NewColumn", {"HESAP NO", "HESAP ADI", "Nisan - 2016", "Haziran - 2016", "Temmuz - 2016", "Ağustos - 2016", "Eylül - 2016", "Ekim - 2016", "Kasım - 2016", "Aralık - 2016", "Ocak - 2017", "Şubat - 2017", "Mart - 2017", "Mayıs - 2017"}, {"HESAP NO.1", "HESAP ADI.1", "Nisan - 2016", "Haziran - 2016", "Temmuz - 2016", "Ağustos - 2016", "Eylül - 2016", "Ekim - 2016", "Kasım - 2016", "Aralık - 2016", "Ocak - 2017", "Şubat - 2017", "Mart - 2017", "Mayıs - 2017"})
in
    #"Expanded NewColumn"

另一个问题:

let
    Source = #"Tum Hareketler",
    #"Sorted Rows" = Table.Sort(Source,{{"DATE_", Order.Ascending}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Sorted Rows", "DATE_", "DATE_ - Copy"),
    #"Extracted Month Name" = Table.TransformColumns(#"Duplicated Column", {{"DATE_", each Date.MonthName(_, "tr-TR"), type text}}),
    #"Extracted Year" = Table.TransformColumns(#"Extracted Month Name",{{"DATE_ - Copy", Date.Year}}),
    #"Added Custom" = Table.AddColumn(#"Extracted Year", "Tarih", each [DATE_] & " - " & Number.ToText([#"DATE_ - Copy"], "G","")),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"HESAP NO", "HESAP ADI", "Tarih"}, {{"Sum Alacak", each List.Sum([ALACAK]), type number}}),
    #"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[Tarih]), "Tarih", "Sum Alacak", List.Sum)
in
    #"Pivoted Column"

1 个答案:

答案 0 :(得分:0)

首先我将“Tarih”列表转换为表格,

然后设法编写以下查询:

let
    Liste = Tarih,
    TarihListe = Liste [Column1],
    Source = #"320 Odemeler",
    #"Merged Queries" = Table.NestedJoin(Source,{"HESAP NO"},#"320 Faturalar",{"HESAP NO"},"NewColumn",JoinKind.LeftOuter),
    #"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries", "NewColumn", TarihListe , TarihListe )
in
    #"Expanded NewColumn"

因此,每次通过数据透视表列添加新月份列时,我都不必编辑查询以将其添加到查询...