Power Query Parameter在一个表中工作,但不在另一个表中工作

时间:2014-11-24 17:31:34

标签: powerquery

所以我有两个表(电源查询),并希望将它们合二为一。第二个表只是查看第一个表(电源查询)并对其应用参数过滤器。当我尝试将参数代码组合到原始查询中时,过滤器不起作用。我已启用快速组合以公开所有查询以消除任何防火墙问题。

为了不打破pq的原始工作集,我复制第一个pq并使用advanced修改所需的代码来应用参数(第三个pq)

第二个电源查询代码(这看第一个pq应用参数过滤器)并且可以正常工作

let
    Date_Parameter = Excel.CurrentWorkbook(){[Name="Parameter"]}[Content],
    Date_Value = Date_Parameter{0}[Value],
    Source = Excel.CurrentWorkbook(){[Name="Timesheet1"]}[Content],
    #"Filtered Rows" = Table.SelectRows(Source, each ([Date] = Date_Value))
in
    #"Filtered Rows"

第三个电源查询代码(这是我复制第一个pq并从第二个pq添加参数代码的代码)这不起作用

let

    Date_Parameter = Excel.CurrentWorkbook(){[Name="Parameter"]}[Content],
    Date_Value = Date_Parameter{0}[Value],

    Source = Excel.Workbook(File.Contents("\\192.168.12.31\Project Files\Daily Truck Sheet\TimeTrack\TimeTrack.xlsm")),
    Timesheet_Table = Source{[Item="Timesheet",Kind="Table"]}[Data],
    Merge = Table.NestedJoin(Timesheet_Table,{"Ref"},Project,{"Ref"},"NewColumn"),
    #"Expand NewColumn" = Table.ExpandTableColumn(Merge, "NewColumn", {"Crew"}, {"NewColumn.Crew"}),
    #"Renamed Columns"  = Table.RenameColumns(#"Expand NewColumn",{{"NewColumn.Crew", "Crew"}}),
    #"Removed Duplicates" = Table.Distinct(#"Renamed Columns", {"Ref"}),
    #"Removed Columns"  = Table.RemoveColumns(#"Removed Duplicates",{"Ref", "Employee Name", "Truck #", "Hours", "Per Diem", "Piecework", "Travel Day", "Timecard Filename", "Paid DT Hrs.", "hours check", "project hours", "Paid Regular Hours", "Paid  OT  Hrs.", "PayPeriod", "Employee Number", "Lead Hand Employee Number", "Crew Count", "Employee Revenue"}),
    #"Reordered Columns"= Table.ReorderColumns(#"Removed Columns",{"Date", "Date Received", "Lead Hand", "Crew", "Project#", "Comments", "Work Performed", "time card hours", "Revenue per hour", "Total Reveneu"}),
    Rounding = Table.TransformColumns(#"Reordered Columns",{{"Revenue per hour", each Number.Round(_, 2)}, {"Total Reveneu", each Number.Round(_, 2)}}),
    #"Filtered Rows" = Table.SelectRows(Rounding, each ([Date] = Date_Value))
in
    #"Filtered Rows"

1 个答案:

答案 0 :(得分:0)

所以我不得不为pq插入一个变换来作为日期。即使在参数pq(从参数表加载值)中,它已经被转换。用源代码替换了源代码行之前的前三行,并且工作正常

Date_Parameter = Excel.CurrentWorkbook(){[Name="Parameter"]}[Content],
#"Changed Type1" = Table.TransformColumnTypes(Date_Parameter,{{"Value", type date}}),
Date_Value = #"Changed Type1"{0}[Value],

所以也许现在我可以摆脱参数pq,因为它全都内置在最终的pq中但还没有尝试过