Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I have reviewed Solved: Lookup value within date range - Microsoft Power BI Community and other related posts of matching a date in one table to a date range in a second table. However, these examples seem to assume that there is another categorical variable that I can use for the initial inner-join. My situation is different.
I have a list of dates:
2019-01-01
2020-01-01
2021-01-01
2022-01-01
and I have a list of intervals
start stop Categorical_Value
2019-01-01 2019-12-31 A
2019-12-31 2020-01-02 B
2019-12-31 2023-01-01 C
2020-01-02 2021-12-30 D
For each date (first list), I want to know which intervals overlap with that list, so for 2019-01-01 I would like a record of the date and null values for start, stop and categorical_value.
Date start stop categorical value
2019-01-01 2019-12-31 2020-01-02 B
2020-01-01 2019-12-31 2023-01-01 C
Appropriate DAX for ths sort of join/lookup completely escapes me.
R
Solved! Go to Solution.
Hi, @busmansholiday
Is this you expected result?
If so, you may need to join the two tables before filtering the data, because it is currently difficult to expand the rows by measure. 'lookupvalue' also does not apply to row data expansion.
Sample:
New Table =
VAR tab =
CROSSJOIN ( List, 'Table' )
VAR tab2 =
FILTER ( tab, List[Date] > 'Table'[start] && List[Date] < 'Table'[stop] )
RETURN
tab2
Best Regards,
Community Support Team _ Eason
Hi, @busmansholiday
Is this you expected result?
If so, you may need to join the two tables before filtering the data, because it is currently difficult to expand the rows by measure. 'lookupvalue' also does not apply to row data expansion.
Sample:
New Table =
VAR tab =
CROSSJOIN ( List, 'Table' )
VAR tab2 =
FILTER ( tab, List[Date] > 'Table'[start] && List[Date] < 'Table'[stop] )
RETURN
tab2
Best Regards,
Community Support Team _ Eason
@busmansholiday , assume the first date is an independent table
then you create a measure like this
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
return
countrows(filter(Table2, Table2[Start Date] <= _max && Table2[End Date] >= _max ))
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
23 | |
21 | |
20 | |
13 | |
12 |
User | Count |
---|---|
43 | |
31 | |
24 | |
22 | |
22 |