Forum Discussion
Richard_Halsall
2 years agoHelper IV
Fill missing dates in rows based on value from another table
Hi, after searching the help topics I am still requiring help to complete what would seem a simple requirement. I have 2 tables as shown containing Payroll Dates and Contractor Payroll Dates Pa...
- 2 years ago
You have to replace first two steps with your table references. If you don't know how to do it - check comments below.
Result:
let PayrollDates = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc/LCUAhEEPRXmYtmBn/tYj9t/HE8CDLnFXu3hYzw3MgqiVzO+nSEopHBUKF5EL10d2InxophDqpCA1SFZqkJrRIXchBG2r8j6nGACw1FjjUbsL5AA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [PayrollDate = _t, PayrollDayNumber = _t]), ContractorPayrollDates = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSjQwCjQ2AAFDDzPPVE9HbyUdJSNLfQNDfSMDIxOlWB0caowNiFBjSFgNUIGBESE1RkSoMSZCjQkRakyJUGNGhBpzPGo8PB0NCLkHpgafe2BqkNwTCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Contractor__c = _t, Site_Start_Date__c = _t]), ChangedTypePayrollDates = Table.TransformColumnTypes(PayrollDates,{{"PayrollDate", type date}, {"PayrollDayNumber", Int64.Type}}, "sk-SK"), ChangedTypeContractorPayrollDates = Table.TransformColumnTypes(ContractorPayrollDates,{{"Site_Start_Date__c", type date}}), GroupedRows = Table.Group(ChangedTypeContractorPayrollDates, {"Contractor__c"}, {{"All", each _, type table [Contractor__c=nullable text, Site_Start_Date__c=nullable date]}}), Ad_PayrollDates = Table.AddColumn(GroupedRows, "PayrollDates", each ChangedTypePayrollDates, type table), ExpandedPayrollDates = Table.ExpandTableColumn(Ad_PayrollDates, "PayrollDates", {"PayrollDate", "PayrollDayNumber"}, {"PayrollDate", "PayrollDayNumber"}), Ad_SiteStartDateC = Table.AddColumn(ExpandedPayrollDates, "Site_Start_Date__c", each if List.Contains([All][Site_Start_Date__c], [PayrollDate]) then [PayrollDate] else null, type date), RemovedColumns = Table.RemoveColumns(Ad_SiteStartDateC,{"All"}), ReorderedColumns = Table.ReorderColumns(RemovedColumns,{"Contractor__c", "Site_Start_Date__c", "PayrollDate", "PayrollDayNumber"}) in ReorderedColumns
dufoq3
2 years agoCommunity Champion
You have to replace first two steps with your table references. If you don't know how to do it - check comments below.
Result:
let
PayrollDates = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Tc/LCUAhEEPRXmYtmBn/tYj9t/HE8CDLnFXu3hYzw3MgqiVzO+nSEopHBUKF5EL10d2InxophDqpCA1SFZqkJrRIXchBG2r8j6nGACw1FjjUbsL5AA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [PayrollDate = _t, PayrollDayNumber = _t]),
ContractorPayrollDates = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSjQwCjQ2AAFDDzPPVE9HbyUdJSNLfQNDfSMDIxOlWB0caowNiFBjSFgNUIGBESE1RkSoMSZCjQkRakyJUGNGhBpzPGo8PB0NCLkHpgafe2BqkNwTCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Contractor__c = _t, Site_Start_Date__c = _t]),
ChangedTypePayrollDates = Table.TransformColumnTypes(PayrollDates,{{"PayrollDate", type date}, {"PayrollDayNumber", Int64.Type}}, "sk-SK"),
ChangedTypeContractorPayrollDates = Table.TransformColumnTypes(ContractorPayrollDates,{{"Site_Start_Date__c", type date}}),
GroupedRows = Table.Group(ChangedTypeContractorPayrollDates, {"Contractor__c"}, {{"All", each _, type table [Contractor__c=nullable text, Site_Start_Date__c=nullable date]}}),
Ad_PayrollDates = Table.AddColumn(GroupedRows, "PayrollDates", each ChangedTypePayrollDates, type table),
ExpandedPayrollDates = Table.ExpandTableColumn(Ad_PayrollDates, "PayrollDates", {"PayrollDate", "PayrollDayNumber"}, {"PayrollDate", "PayrollDayNumber"}),
Ad_SiteStartDateC = Table.AddColumn(ExpandedPayrollDates, "Site_Start_Date__c", each if List.Contains([All][Site_Start_Date__c], [PayrollDate]) then [PayrollDate] else null, type date),
RemovedColumns = Table.RemoveColumns(Ad_SiteStartDateC,{"All"}),
ReorderedColumns = Table.ReorderColumns(RemovedColumns,{"Contractor__c", "Site_Start_Date__c", "PayrollDate", "PayrollDayNumber"})
in
ReorderedColumnsRichard_Halsall
2 years agoHelper IV
Many thanks worked perfectly