cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
gcampanine Frequent Visitor
Frequent Visitor

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

Accepted Solutions
gcampanine Frequent Visitor
Frequent Visitor

Re: Find matching value in related column and return link

@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" )

 

 

2 REPLIES 2
Community Support Team
Community Support Team

Re: Find matching value in related column and return link

@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.
gcampanine Frequent Visitor
Frequent Visitor

Re: Find matching value in related column and return link

@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
GregDeckler

How to Get Your Question Answered Quickly

Power BI Super User, Greg Deckler, explains

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Ideas
Users Online
Currently online: 59 members 1,272 guests
Please welcome our newest community members: