Forum Discussion
Merge table with a condition with power query
- 3 years ago
Hi Islem
You can first merge Table 2 to Table 1 by Customer column. This will add a [Table 2] column in Table 1.
Then add a custom column with below code. This will get the responsible sales person in corresponding period.
let _salesDate = [Date] in Table.Last(Table.Sort(Table.SelectRows([Table 2], each [Date] <= _salesDate), {"Date", Order.Ascending}))[Sales responsible]After that, remove the [Table 2] column from Table 1. PBIX file has been attached at bottom.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi Islem
You can first merge Table 2 to Table 1 by Customer column. This will add a [Table 2] column in Table 1.
Then add a custom column with below code. This will get the responsible sales person in corresponding period.
let _salesDate = [Date] in Table.Last(Table.Sort(Table.SelectRows([Table 2], each [Date] <= _salesDate), {"Date", Order.Ascending}))[Sales responsible]
After that, remove the [Table 2] column from Table 1. PBIX file has been attached at bottom.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
great solution, many thanks dear