Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I would like to use lookup with a condition, but there is some duplicates value in the ID table. There are two tables UserId table & ID table. Check id from ID table with Date & where it falls in UserId table column- StartDate, EndDate depends on that assign userid for that Id. If the End date of UserId table blank consider Today().
UserId Table
| UserID | ID | StartDate | EndDate |
| A | 1 | 04-09-2018 | 03-03-2019 |
| B | 1 | 03-03-2019 |
ID Table
| ID | Date | Expected UserID |
| 1 | 01-09-2018 | |
| 1 | 02-09-2018 | |
| 1 | 03-09-2018 | |
| 1 | 04-09-2018 | |
| 1 | 05-09-2018 | A |
| 1 | 17-10-2018 | A |
| 1 | 01-03-2019 | A |
| 1 | 02-03-2019 | A |
| 1 | 03-03-2019 | A |
| 1 | 04-03-2019 | B |
| 1 | 05-03-2019 | B |
| 1 | 06-03-2019 | B |
| 1 | 1-1-2020 | B |
Solved! Go to Solution.
hi @Anonymous
try a measure
Expected UserID =
CALCULATE(FIRSTNONBLANK('UserId Table'[UserId], 1),
FILTER(ALL('UserId Table'), 'UserId Table'[StartDate] < SELECTEDVALUE('ID Table'[Date]) && ('UserId Table'[EndDate] >= SELECTEDVALUE('ID Table'[Date]) || ISBLANK('UserId Table'[EndDate]))
)
If you have duplicates, use MAXX with a FILTER instead of LOOKUPVALUE.
hi @Anonymous
try a measure
Expected UserID =
CALCULATE(FIRSTNONBLANK('UserId Table'[UserId], 1),
FILTER(ALL('UserId Table'), 'UserId Table'[StartDate] < SELECTEDVALUE('ID Table'[Date]) && ('UserId Table'[EndDate] >= SELECTEDVALUE('ID Table'[Date]) || ISBLANK('UserId Table'[EndDate]))
)
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 21 | |
| 10 | |
| 7 | |
| 7 |