Forum Discussion

smpa01's avatar
smpa01
Icon for Community Champion rankCommunity Champion
8 years ago
Solved

Lookup based on partial value in power query

Hi,
I have the following data

NAME ID Partial Name
SAM JONES 123 SAM
TOM CLIFF 234 TOM

If I want to bring the ID based on the partial value of I can do the following in excel and it would bring the ID based o the partial value

NAME ID Partial Name Partial Name2
SAM JONES 123 SAM *SAM*
TOM CLIFF 234 TOM *TOM*

Index(B1:B3,Match(D2,A1:A3,0))

I was wondering if Power Query has the similar capacities.

Thank you in advance.
  • Hi smpa01,

     

    If I understand you correctly, a simple DAX formula could do that.

     

    I assume you have a table called "Table1" with NAME and ID column.

     

     

    And another table called "Table2" with Partial Name column.

     

     

    Then you should be able to use the formula below to create a calculate column in "Table2" to get ID from "Table1" based on the value of Partial Name. :smileyhappy:

    Column = 
    CALCULATE (
        MAX ( Table1[ID] ),
        FILTER ( Table1, SEARCH ( Table2[Partial Name], Table1[NAME],, 0 ) > 0 )
    )
    

     

    Regards

3 Replies

  • v-ljerr-msft's avatar
    v-ljerr-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi smpa01,

     

    If I understand you correctly, a simple DAX formula could do that.

     

    I assume you have a table called "Table1" with NAME and ID column.

     

     

    And another table called "Table2" with Partial Name column.

     

     

    Then you should be able to use the formula below to create a calculate column in "Table2" to get ID from "Table1" based on the value of Partial Name. :smileyhappy:

    Column = 
    CALCULATE (
        MAX ( Table1[ID] ),
        FILTER ( Table1, SEARCH ( Table2[Partial Name], Table1[NAME],, 0 ) > 0 )
    )
    

     

    Regards

    • smpa01's avatar
      smpa01
      Icon for Community Champion rankCommunity Champion

      v-ljerr-msftthanks for the solution. Is there a way to achieve this in Power Query by any chance - searching a column of Partial Text Strings in another list of column containing Text Strings.

  • smpa01's avatar
    smpa01
    Icon for Community Champion rankCommunity Champion
    NAME -------------ID----------Partial Name
    SAM JONES----123--------SAM
    TOM CLIFF------234--------TOM

    NAME------------ID---Partial Name------Partial Name2
    SAM JONES-------123------SAM-------*SAM*
    TOM CLIFF---------234-------TOM-------*TOM*