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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Charlie1234
New Member

Look up multiple values from one cell

Hi,

 

I have a column in one of my data sources that holds staff ID numbers, but I need it to show as the staff members name.

 

I've used a lookup value against another table, but the trouble I am having is that it's not returning all the names because there are multiple staff ID's per cell in each line of data in the table as it was a "Table" but I extracted the values.

 

The dax/new column I have used is:

 

DAX:Project Team Staff Names = COMBINEVALUES(" ",LOOKUPVALUE('User Information List (2)'[FirstName], 'User Information List (2)'[Id], 'Project Highlight'[ProjectTeam(StaffInvolved_Id]),LOOKUPVALUE('User Information List (2)'[LastName], 'User Information List (2)'[Id], 'Project Highlight'[ProjectTeam(StaffInvolved_Id]))"

 

...which will only return data with a single ID.

 

I'll provide tan example below so you can see what I mean - the cell with multiple values won't return names. Ideally I'd like it to return all the IDs as names in that new column.

 

Any help would be great - apologies, I am not well versed in PBi as I only use it occasionally.

 

Project Team (Staff Involved ID)Project Team Staff Names (as per dax above)
643"Person A First Name" "Person A Last Name"
99, 26, 41, 579, 43, 181, 78, 145, 124, 173, 1033, 28, 27, 766, 300, 643 

336

"Person B First Name" "Person B Last Name"
1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Charlie1234 

According to your description, you want to lookup value from one table by ids , and in a row , you have multiple ids.

For your need , here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1686736670660.png

vyueyunzhmsft_1-1686736685081.png

(2)We can click "New Column" and enter this:

Column = VAR Items1 = SUBSTITUTE ( [IDs], ",", "|" )
VAR T1 = GENERATESERIES ( 1, COALESCE ( PATHLENGTH ( Items1 ), 1 ), 1 )
VAR T2 = SELECTCOLUMNS ( T1, "@Item", PATHITEM ( Items1, [Value] ) )
var T3 = ADDCOLUMNS(T2, "name" , LOOKUPVALUE('Name'[FirstName],'Name'[ID],VALUE([@Item])) & LOOKUPVALUE('Name'[LastName],'Name'[ID],VALUE([@Item])))
return
CONCATENATEX(T3, [name] , ",")

 

Then wen can get this:

vyueyunzhmsft_2-1686736714432.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
v-yueyunzh-msft
Community Support
Community Support

Hi , @Charlie1234 

According to your description, you want to lookup value from one table by ids , and in a row , you have multiple ids.

For your need , here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1686736670660.png

vyueyunzhmsft_1-1686736685081.png

(2)We can click "New Column" and enter this:

Column = VAR Items1 = SUBSTITUTE ( [IDs], ",", "|" )
VAR T1 = GENERATESERIES ( 1, COALESCE ( PATHLENGTH ( Items1 ), 1 ), 1 )
VAR T2 = SELECTCOLUMNS ( T1, "@Item", PATHITEM ( Items1, [Value] ) )
var T3 = ADDCOLUMNS(T2, "name" , LOOKUPVALUE('Name'[FirstName],'Name'[ID],VALUE([@Item])) & LOOKUPVALUE('Name'[LastName],'Name'[ID],VALUE([@Item])))
return
CONCATENATEX(T3, [name] , ",")

 

Then wen can get this:

vyueyunzhmsft_2-1686736714432.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thank you this is exactly what I was looking for!

lbendlin
Super User
Super User

that sounds doable.   Please provide sanitized sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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