Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Dear all, good day
Two tables:
Table 1 has these fields , Start Date 、End Date 、Location.
Table 2 has Date Filed , how to estimate the date in which period and get the Location Value.
Please see screenshot below.
Solved! Go to Solution.
Hello, @chuyiyi
let
Table1 = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Table2 = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
combo = Table.RenameColumns(Table1, {"Start Date", "Order Date"}) & Table.AddColumn(Table2, "mark", each 1),
sort = Table.Sort(combo,{{"Order Date", Order.Ascending}, {"mark", Order.Descending}}),
fdown = Table.FillDown(sort,{"Location"}),
filter = Table.SelectRows(fdown, each ([mark] = 1)),
select = Table.SelectColumns(filter,{"Location", "Order Date"})
in
select
Hello, @chuyiyi
let
Table1 = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Table2 = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
combo = Table.RenameColumns(Table1, {"Start Date", "Order Date"}) & Table.AddColumn(Table2, "mark", each 1),
sort = Table.Sort(combo,{{"Order Date", Order.Ascending}, {"mark", Order.Descending}}),
fdown = Table.FillDown(sort,{"Location"}),
filter = Table.SelectRows(fdown, each ([mark] = 1)),
select = Table.SelectColumns(filter,{"Location", "Order Date"})
in
select
The question and visually efficient pattern caught my attention.
While adding this pattern to a project I had open, I noticed
that if you add new values to Table 2 that are not in a range of
Table 1, there is no logic to handle this condition and say
return a blank or null. Would you have a moment to add
handling for an out-of-range condition?
Table 1 lookup ranges include:
Update Table 2 entries to include 2018-12-31 and 2023-01-01
that are not included in the Table 1 ranges.
I would have expected 2018-12-31 to return blank, however
would not have expected 2023-01-01 to return a match of
Location C.
Query Results:
Hi, @foodd how about this?
let
Table1 = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Table2 = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
combo = Table.AddColumn(Table1, "Order Date", each [Start Date]) & Table.AddColumn(Table2, "mark", each 1),
sort = Table.Sort(combo,{{"Order Date", Order.Ascending}, {"mark", Order.Descending}}),
fdown = Table.FillDown(sort,{"Location", "End Date"}),
filter = Table.SelectRows(fdown, each ([mark] = 1)),
later = Table.ReplaceValue(filter, each [Order Date] > [End Date], null, (v, o, n) => if o then n else v, {"Location"}),
select = Table.SelectColumns(later,{"Location", "Order Date"})
in
select
In power query.
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 5 | |
| 5 | |
| 4 |