Wizhi
Wizhi

Reputation: 6549

DAX, IF function, use two types of data types (numeric and text)

I wonder if you can use two kind of data types in the DAX, IF formula.

I want to calculate the EPS value. If it's positive, I want to return the value. If it's negative, I want to show "(d)" as deficit.

Example code:

=IF([EPS]<=0;"(d)";
IFERROR([EPS];BLANK()))

But I only get the following error message: "The second and third arguments of function IF have different data types"

Is there a workaround of this or a any ideas how I can combine the text and numeric data type in the IF function?.

Upvotes: 1

Views: 2282

Answers (2)

wolf_07
wolf_07

Reputation: 21

Try =IF([EPS]<=0,"(d)")

Note that no value has been specified for value_if_false. Therefore, the function returns the default, which is an empty string.

Upvotes: 2

greggyb
greggyb

Reputation: 3798

Power Pivot for Excel 2016 and in Power BI Desktop can have an IF() function with multiple return types. In 2013, this is not currently possible.

Upvotes: 3

Related Questions