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! Learn more

Reply
mspreng
Frequent Visitor

Lookup table in combination with searching a text string

Long time lurker, first post, hi!

 

I have a table with some billing data and an ID. The ID column has the format xxx/[name]/xxx... OR xxx/yyy/zzz/[name] and the [name]'s in this ID string may or may not have a prefix or suffix.

 

I also have a table of "base" names that I want to search for in the ID so that I can slice and sum based on these names.

 

I'm trying to create a column where any ID that has an occurance of any of the Names from the Name list would just copy that Name to the new column.

 

This is the if statement that works for just one, but I need to be able to search each ID for all of the potential names and then use that name in the new column.
Base Name = if(search("abcd", 'Table1'[ID], 1, 0) > 0,"abcd","")

 

Example of results:

 

Table 1

ID                                           base name (new calc column)

xxx/abcd/yyy                          abcd

x/abcd-suffix/zzz/a                abcd

yyy/x/zzz/efgh                       efgh

 

Table 2

Names

abcd

efgh

etc

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hey @mspreng

 

Your situations seems pretty interesting, but I've done a video on something very similar to this that I think might help you out. I don't have the exact link right now but if you go to youtube.com/c/bielite you can search for the "VLOOKUP" video I did a couple weeks back. The gist is to use the CONCATENATEX function to loop through all of your potential names and then the SEARCH function like you have already done.

 

Hope this helps,

Parker

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hey @mspreng

 

Your situations seems pretty interesting, but I've done a video on something very similar to this that I think might help you out. I don't have the exact link right now but if you go to youtube.com/c/bielite you can search for the "VLOOKUP" video I did a couple weeks back. The gist is to use the CONCATENATEX function to loop through all of your potential names and then the SEARCH function like you have already done.

 

Hope this helps,

Parker

Hi @Anonymous,

 

Very nice solution !
Any chance you know how we can accomplish this in Power query rahter than in DAX?

I have searched all over, but haven't been able to find a solution, where we are "looking up" text values, in the same way the lookup works in Excel.

In Excel we can lookup approximate text values using this formular:

=Lookup(2^15,Find('Sheet1'!$M$4:$M$21,$J7),'Sheet1'!$O$4,$O$21)

 

Thanks in advance,

Espen

Hello @Anonymous,

Thanks a lot for the video , That's precisely what I was looking for as well.

I have a scenario a bit different. We would like to use a dynamic table (Resultset from a selectcolumn + Search) as the source table rather than the static tabel in example.

 

Do you think that'd be possible ?

 

PS: We are going to use this pattern an Defining Roles for Row Level Security.

Detailed Query: https://community.powerbi.com/t5/Desktop/Lookup-table-in-combination-with-searching-a-text-string/m-p/496521#M231556

Parker, this was EXACTLY it. Thank you for the well done and very clear video. I also had not been able to find a clear writeup on this anywhere. I will definitely be coming back to your channel for more tutorials.

 

Cheers!

 

Direct link to Parker's video: https://www.youtube.com/watch?v=_bdHe3z_fVU

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors