Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
Solved! Go to Solution.
@v-chuncz-msft thank you for your response!
I reached another solution, a bit more complicated, but it worked just fine
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" )
You may just use LOOKUPVALUE.
Column = LOOKUPVALUE ( Plan[link], Plan[Code], Bank[Code], "my-link" )
@v-chuncz-msft thank you for your response!
I reached another solution, a bit more complicated, but it worked just fine
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" )
User | Count |
---|---|
76 | |
75 | |
46 | |
31 | |
27 |
User | Count |
---|---|
99 | |
91 | |
51 | |
48 | |
47 |