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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BILearn
Frequent Visitor

Help with Look up

Hi all,

I am trying to look up in Power BI, Sample file here (Link updated)

I need to lookup the column "location" from the 'Lookup Table' to 'My Table'

BILearn_1-1642205350586.png

 

The Video ID is used to link between two tables. However the video ID has duplicates in it.

Question- How can I create a new column 'Location' in My Table and lookup the location values from Lookup Table that has the lowest Sequence number.( Sequence number can be random)

Also keen to know how to do the opposite(location that has highest sequence number)

Can you please help.

Thanks in advance.

1 ACCEPTED SOLUTION
sevenhills
Super User
Super User

Not able to download the file easily ...  

 

I came up with these DAX for the column

 

1) Error! obvisouly, but presenting to you

 

Column 2 = LOOKUPVALUE('Lookup Table'[Location],'Lookup Table'[Video ID], 'My Table'[Video ID])

 

 

2) Random - first non blank lookup 

 

Column = CALCULATE( FIRSTNONBLANK('Lookup Table'[Location], 1), FILTER(all('Lookup Table'), 'Lookup Table'[Video ID] = 'My Table'[Video ID]))

 

 

3) To get the top 1 location value, sorted by sequence number descending 

 

Column 3 = 
var _c = 'My Table'[Video ID]
var _rv = SELECTCOLUMNS( TOPN(1, CALCULATETABLE('Lookup Table','Lookup Table'[Video ID] = _c), 'Lookup Table'[Sequence Number], 0 ), "Location", 'Lookup Table'[Location])

return _rv 

 

 

4) To get the location value, sorted by sequence number ascending

 

 

Column 4 = 
var _c = 'My Table'[Video ID]
var _rv = SELECTCOLUMNS( TOPN(1, CALCULATETABLE('Lookup Table','Lookup Table'[Video ID] = _c), 'Lookup Table'[Sequence Number], 1 ), "Location", 'Lookup Table'[Location])

return _rv 

 

 

 

View solution in original post

4 REPLIES 4
BILearn
Frequent Visitor

Thank you. @sevenhills , I'll try your solution.

Also Thanks @aj1973 .

Please see the updated link in the original post.

sevenhills
Super User
Super User

Not able to download the file easily ...  

 

I came up with these DAX for the column

 

1) Error! obvisouly, but presenting to you

 

Column 2 = LOOKUPVALUE('Lookup Table'[Location],'Lookup Table'[Video ID], 'My Table'[Video ID])

 

 

2) Random - first non blank lookup 

 

Column = CALCULATE( FIRSTNONBLANK('Lookup Table'[Location], 1), FILTER(all('Lookup Table'), 'Lookup Table'[Video ID] = 'My Table'[Video ID]))

 

 

3) To get the top 1 location value, sorted by sequence number descending 

 

Column 3 = 
var _c = 'My Table'[Video ID]
var _rv = SELECTCOLUMNS( TOPN(1, CALCULATETABLE('Lookup Table','Lookup Table'[Video ID] = _c), 'Lookup Table'[Sequence Number], 0 ), "Location", 'Lookup Table'[Location])

return _rv 

 

 

4) To get the location value, sorted by sequence number ascending

 

 

Column 4 = 
var _c = 'My Table'[Video ID]
var _rv = SELECTCOLUMNS( TOPN(1, CALCULATETABLE('Lookup Table','Lookup Table'[Video ID] = _c), 'Lookup Table'[Sequence Number], 1 ), "Location", 'Lookup Table'[Location])

return _rv 

 

 

 

@sevenhills Thank you, much appreciate your help.

 

 

aj1973
Community Champion
Community Champion

Hi @BILearn 

The download needs a login and password, Can you share it publicly through other service please?

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.