Laki
Laki

Reputation: 99

DAX don't support comparing values of type integer with values type of text

This is DAX formula in Power BI that should create new measure in a table but I faced error saying

DAX don't support comparing values of type integer with values type of text...

This formula is designed to calculated Sum of the Offers for the previous year vs selected one. Offer[Year] is decimal field used in the formula is decimal type:

Offer Amount Prev Year = IF(HASONEVALUE(Offer[Year]), CALCULATE(SUM(Offer[Offer Amount]), Offer[Year] = FORMAT(VALUES(Offer[Year]) - 1, BLANK())))

How to solve the error from above?

Upvotes: 1

Views: 30764

Answers (1)

Foxan Ng
Foxan Ng

Reputation: 7151

The error lies at the FORMAT function.

Offer[Year] is an integer while FORMAT(VALUES(Offer[Year]) - 1, BLANK()) is text, hence DAX don't support comparing the two values.

If you remove the FORMAT function then it should be working.

Offer Amount Prev Year = 
IF(
    HASONEVALUE(Offer[Year]),
    CALCULATE(
        SUM(Offer[Offer Amount]),
        Offer[Year] = VALUES(Offer[Year]) - 1
    )
)

Upvotes: 3

Related Questions