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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Search across two tables, for similair data

Hi

 

I trying to repeat a DAX calculation discused by Pragmatic Works here https://youtu.be/eKgcLcrebzI (44mins 41 sec for the actual full expression).  This was to help deal with bad data basically.  So I have managed to get this to expression to work on another project with some success, but when I tried it for my new project all failed.  I think it could be to do with SEARCH is a scalar function and I am needing "row by row" context; please correct me if I am getting the evaluation context aspect wrong, and I need a filter for Row Context..

 

So this i my example - 

 

Search for similiar data in columnsSearch for similiar data in columns

 

Table 1: My main reference table, this has the a full user names and cost centre codes.  My starting point.

Table 2: This is my imported data, excel report, there are a number of columns in this table but I am only looking at the one column called name. 

Step1 Match: So I am wanting search for the name from table one and see if exists in table two, if not then just a blank field.

Step2Remove: the final or outcome once I or DAX removes the blanks.  So the first column is what I imported, column two is the correct full name and its cost centre.  

My model has several other table, which are a one-to-many relationship. Would this be a factor as to why the expression is maybe not working?

 

This is my attemp at the DAX expression:

 
Match Name =
calculate(
            MAX('Portfolio1'[NAME]),
            should there be a filter here??
            SEARCH('Portfolio1'[NAME], ImportedData[NAME],,0)
)>0

 

 

The relationship with Portfolio1 to ImportedData, is a ONE-TO-MANY

 

Many thanks

Chris Carpenter

 

2 REPLIES 2
Anonymous
Not applicable

@Anonymous As your imported name doesn't have complete name so I'm matching first character of first name and last name. Please try below measure. Let me know if it works

Measure = 
VAR _imported = MAX(Imported[Name])
VAR _secondName = RIGHT(_imported,LEN(_imported)-SEARCH(" ",_imported,1,0))
RETURN CALCULATE(MAX(Portfolio[Code]),FILTER(Portfolio,SEARCH(LEFT(_imported,1),LEFT(Portfolio[Name],1),1,0)&&SEARCH(_secondName,Portfolio[Name],1,0)))
Anonymous
Not applicable

Hi vimal_parma

 

Thats is looking very good :), this works fine when I have 'First Name' followed by 'Last Name', but if these are swapped around then I get a diffrenet result. For example if I change "M PLANT" to "PLANT M" the layout changes.

 

Chris

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.