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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gcampanine
Advocate II
Advocate II

Find matching value in related column and return link

Hello everyone!

 

I have two tables:
Table 1 (let's call it "Bank") has a code number for each registered bank and its name (it comes from our database);
Table 2 (let's call it "Plan") has a code number for each bank and a link to its logo image in google drive (it comes from an Excel file).

 

All codes in Plan are in Bank, but not all codes in Bank exist in Plan.

 

I need to create a calculated column in Plan that checks if the selected value in Bank exists in Plan. If it exists, then the column shows the corresponding link. If not, then it shows a specific link.

I am using the Simple Image visual to show the image, so the link column is marked as Image URL. This visual only accepts a column as value.

 

I have tried this dax expression:

Coluna = 
IF(
    SELECTEDVALUE(Bank[Code]) IN Plan;
    Plan[link];
    "my-link"
)

but I am getting an error saying that "function CONTAINSROW must have a value for each column in the table expression.

 

Anyone have any idea about how to solve this?

Thank you!


EDIT:

I tried this dax expression:

Coluna = 
IF(
    HASONEVALUE(Plan1[banco]);
    SELECTEDVALUE(Plan1[link 3]);
    "my-link"
)

but it always shows the static link image, no matter if there is a corresponding image to the selected bank code.

1 ACCEPTED SOLUTION

@v-chuncz-msft thank you for your response!

 

I reached another solution, a bit more complicated, but it worked just fine Smiley LOL

I created this calculated column in Bank, because I realized that my logic of creating it in Plan was wrong:

 

Coluna =
VAR CHECK =
    CALCULATE (
        COUNTROWS ( Plan ),
        FILTER ( Plan, Plan[code] = EARLIER ( Bank[Code] ) )
    ) > 0
VAR LINK =
    CALCULATE (
        FIRSTNONBLANK ( Plan[link], Plan[link] ),
        ALLEXCEPT ( Bank, Plan[code] )
    )
RETURN
    IF ( CHECK, LINK, "my-link" )

 

 

View solution in original post

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@gcampanine 

 

You may just use LOOKUPVALUE.

Column =
LOOKUPVALUE ( Plan[link], Plan[Code], Bank[Code], "my-link" )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft thank you for your response!

 

I reached another solution, a bit more complicated, but it worked just fine Smiley LOL

I created this calculated column in Bank, because I realized that my logic of creating it in Plan was wrong:

 

Coluna =
VAR CHECK =
    CALCULATE (
        COUNTROWS ( Plan ),
        FILTER ( Plan, Plan[code] = EARLIER ( Bank[Code] ) )
    ) > 0
VAR LINK =
    CALCULATE (
        FIRSTNONBLANK ( Plan[link], Plan[link] ),
        ALLEXCEPT ( Bank, Plan[code] )
    )
RETURN
    IF ( CHECK, LINK, "my-link" )

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.