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
Anonymous
Not applicable

IF condition based on another table

Hi,

this is my scenario:

I have 2 tables:

TABLE_1
FK
calculated_column

TABLE2
FK
Boolean_field

My GOAL:
I need to show the content of the calculated_column of TABLE_1 only IF There is "1" in Boolean_field of TABLE2 else I want "N.A."

I tried (inside TABLE_1):
Column = IF(LOOKUPVALUE(TABLE2[Boolean_field]; TABLE2[FK];TABLE_1[FK]) = 1; TABLE_1[calculated_column]; "N.A.")

ERROR: Expressions that yield variant data-type cannot be used to define calculated columns.

 

How can I solve?

 

Thank you

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @Anonymous

 

All rows in a column have to have the same data type. You seem to be assigning text and non-text in your IF.

What data type is TABLE_1[calculated_column]?

It it's a number, one way to solve this would be to substitute the "N.A." by a number that does not come up in the set of values you use and you can easily identify as equivalent to "N.A.". Or use blank() instead of "N.A.", as in:

 

Column =
IF (
    LOOKUPVALUE ( TABLE2[Boolean_field]; TABLE2[FK]; TABLE_1[FK] ) = 1;
    TABLE_1[calculated_column]
)

View solution in original post

1 REPLY 1
AlB
Super User
Super User

Hi @Anonymous

 

All rows in a column have to have the same data type. You seem to be assigning text and non-text in your IF.

What data type is TABLE_1[calculated_column]?

It it's a number, one way to solve this would be to substitute the "N.A." by a number that does not come up in the set of values you use and you can easily identify as equivalent to "N.A.". Or use blank() instead of "N.A.", as in:

 

Column =
IF (
    LOOKUPVALUE ( TABLE2[Boolean_field]; TABLE2[FK]; TABLE_1[FK] ) = 1;
    TABLE_1[calculated_column]
)

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.