Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Need help in Lookup and Condition

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 

UserIDIDStartDateEndDate
A104-09-201803-03-2019
B103-03-2019 

 

ID Table

ID Date Expected UserID
101-09-2018 
102-09-2018 
103-09-2018 
104-09-2018 
105-09-2018A
117-10-2018A
101-03-2019A
102-03-2019A
103-03-2019A
104-03-2019B
105-03-2019B
106-03-2019B
11-1-2020B

 

 

 

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

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]))
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

If you have duplicates, use MAXX with a FILTER instead of LOOKUPVALUE.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
az38
Community Champion
Community Champion

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]))
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.