Forum Discussion

jaimemagana's avatar
jaimemagana
New Member
4 years ago
Solved

Vlookup - PowerBI - Text range or list

Hi there!   I'm trying to obtain the license plate for a number of vehicles, based on how do their license pates end.   Original lookup table:   Year Jan Feb Mar Apr MAy Jun Jul Aug ...
  • v-kkf-msft's avatar
    4 years ago

    Hi jaimemagana ,

     

    You can convert the text to UniCode and then compare them.
    1. First add a new column to table.

     

    NumberCode = 
    UNICODE ( 'Table'[3Letters] ) * 10000
        + UNICODE ( MID ( 'Table'[3Letters], 2, 1 ) ) * 100
        + UNICODE ( RIGHT ( 'Table'[3Letters] ) )

     

    2. Then create the column in plate table.

     

    Lookup = 
    VAR Fir = UNICODE ( [3Letters] )
    VAR Sec = UNICODE ( MID ( [3Letters], 2, 1 ) )
    VAR Thir = UNICODE ( RIGHT ( [3Letters] ) )
    VAR PlateUnicode = Fir * 10000 + Sec * 100 + Thir
    VAR Tab =
        FILTER (
            'Table',
            'Table'[NumberCode]
                = MAXX ( FILTER ( 'Table', [NumberCode] <= PlateUnicode ), [NumberCode] )
        )
    RETURN
        MAXX ( Tab, [Attribute] ) & " " & MAXX ( tab, [Year] )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.