0

So I have two tables (power query), and want to combine them into one. The second table just looks at the first table (power query) and applies a parameter filter to it. When i try to combine the parameter code into the original query the filter doesn't work. I have enabled fast combine to made all queries public to get rid of any firewall issues.

So as not to break the original working set of pq, i duplicated the first pq and modified using advanced by coping the needed code to apply the parameter (third pq)

Second power query code (this looks at first pq an applies a parameter filter) and it works

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"

Third power query code (this is the one where i duplicated the first pq and added parameter code from second pq) this doesn't work

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"
4

1 回答 1

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 中但还没有尝试过

于 2014-11-24T18:56:08.513 回答