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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
kbhalll
Regular Visitor

Doing calculation similar to VLOOKUP in Excel

I am trying to compute a field by matching column Focus Number’s (values like SA-DE105-0000005336) values with another column ‘SA number’ from another table RBIT. If the Focus Number value matches with SA number column, then Focus Number’s values will be retrieved in calculated field. But I am getting blank for the calculated column where there should be a value in Power BI. There are matching values in the both columns mentioned above, I have just given a values’ example above.

Currently I am using the formula below, but it’s not working as mentioned before:

SA number_cal =

VAR optr = TRIM([Focus Number])

RETURN IF(

    optr IN SELECTCOLUMNS(RBIT, "inv", TRIM(RBIT[SA number])),

    [Focus Number],

    BLANK()

)

I have tried a different calculation as well. But it doesn't seems to work.

Would really appreciate any insight that could help solve it. Thanks

1 ACCEPTED SOLUTION
kbhalll
Regular Visitor

I found the root cause of this formula not working, it was actually in another formula not working correctly. Its all working now.

View solution in original post

8 REPLIES 8
kbhalll
Regular Visitor

I found the root cause of this formula not working, it was actually in another formula not working correctly. Its all working now.

Bibiano_Geraldo
Super User
Super User

Hi @kbhalll ,

To achieve your need, you can use the LOOKUPVALUE function as shown bellow.

Make sure to replace column and table names with your owns:

SA number_cal = 
VAR optr = TRIM([Focus Number])
VAR MatchFound = 
    LOOKUPVALUE(
        RBIT[SA number],
        RBIT[SA number], optr
    )
RETURN 
MatchFound



nidhigk
Frequent Visitor

SA number_cal =
VAR optr = TRIM ( [Focus Number] )
RETURN
IF (
CONTAINS (
RBIT,
RBIT[SA number], optr
),
optr,
BLANK ()
)
Please see if this works. 

v-saisrao-msft
Community Support
Community Support

Hi @kbhalll,

Have you had a chance to review the solution we shared by @Kedar_Pande @cengizhanarslan @MasonMA @vaibhavmahajan ? If the issue persists, feel free to reply so we can help further.

 

Thank you.

vaibhavmahajan
Advocate I
Advocate I

Hi @kbhalll ,

I hope you are doing well today 🙂❤️

 

Below are 3 approaches you can try to resolve the VLOOKUP-like issue in your Power BI dashboard/report when matching Focus Number with SA number.

 

Solution 1: Use LOOKUPVALUE

This is the most reliable approach for calculated columns when matching values across tables.

SA number_cal =
VAR MatchValue =
    LOOKUPVALUE (
        RBIT[SA number],
        RBIT[SA number], TRIM ( [Focus Number] )
    )
RETURN
IF (
    NOT ISBLANK ( MatchValue ),
    [Focus Number],
    BLANK ()
)

 

Solution 2: Handle hidden spaces / formatting issues

Sometimes values look identical but contain non-breaking spaces.

Use SUBSTITUTE + UNICHAR(160) to remove non-breaking spaces.

SA number_cal =
VAR FocusClean =
    SUBSTITUTE ( TRIM ( [Focus Number] ), UNICHAR(160), "" )

VAR MatchValue =
    LOOKUPVALUE (
        RBIT[SA number],
        RBIT[SA number],
        SUBSTITUTE ( TRIM ( RBIT[SA number] ), UNICHAR(160), "" )
    )
RETURN
IF ( NOT ISBLANK ( MatchValue ), [Focus Number] )

 

Solution 3: Use a relationship + RELATED (Best practice)

If there is a relationship between the two tables:

Create a relationship between

Focus[Focus Number] → RBIT[SA number]

Then use:

SA number_cal = RELATED ( RBIT[SA number] )

This is the cleanest and most performant solution.

 

Summary RCA and Fix:

Calculated column returning BLANK → Use LOOKUPVALUE

Hidden spaces → Use UNICHAR(160) cleanup

Relationship exists → Use RELATED

IN + SELECTCOLUMNS → Avoid for calculated columns

 

If this answer helped, kindly give Kudos and mark it as the Accepted Solution

to help other members find it more quickly.

 

Best regards,

Vaibhav Mahajan

LinkedIn: https://www.linkedin.com/in/vaibhavnmahajan

MasonMA
Super User
Super User

Hi, 

 

I'd recommend looking at this video How to Perform VLOOKUP in Power BI . 

 

In Power BI, the best practice for VLOOKUP would be to create a relationship from your fact table’s [Focus Number] to RBIT[SA number] (Text to Text), then use RELATED() in a calculated column. 
cengizhanarslan
Super User
Super User

This usually happens because IN SELECTCOLUMNS(...) is very sensitive to data type / hidden characters / row context, especially in a calculated column.

 

If your goal is “VLOOKUP-style: return Focus Number only when it exists in RBIT[SA number]”, do it like this instead:

SA number_cal =
VAR v = TRIM ( 'Table'[Focus Number] )
VAR hit =
    CALCULATE (
        COUNTROWS ( RBIT ),
        FILTER ( RBIT, TRIM ( RBIT[SA number] ) = v )
    )
RETURN
IF ( hit > 0, v, BLANK() )

 

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.
Kedar_Pande
Super User
Super User

@kbhalll 

 

Your current DAX is over‑complicated for a straight “VLOOKUP‑style” match.

Use LOOKUPVALUE (or a relationship + RELATED) instead of IN + SELECTCOLUMNS.

 

If this answer helped, please click Kudos or Accept as Solution.
-Kedar
LinkedIn: https://www.linkedin.com/in/kedar-pande

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.