1
votes

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?

1
Can you provide any sample data and example(s) of what your desired outcome is/are? How to create a Minimal, Complete, and Verifiable example - Joe Gravelyn

1 Answers

3
votes

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
    )
)