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

Error:

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

Cause:

IF based Calculated Columns in Power BI or Power Pivot with 2 different data types is not allowed.

Solution:

Format one data type as needed using FORMAT() function.

</p>
<p>Age = IF (<br />
TableName[Birthday] &lt; TODAY(),<br />
FORMAT (<br />
Year ( TODAY() )- Year ( TableName[Birthday] ),&quot;General Number&quot; ),<br />
&quot;Invalid birth date&quot;<br />
)</p>
<p>

FORMAT Function (DAX): https://msdn.microsoft.com/en-us/query-bi/dax/format-function-dax

Pre-Defined Numeric Formats for the FORMAT function: https://msdn.microsoft.com/query-bi/dax/pre-defined-numeric-formats-for-the-format-function

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.