Forum Discussion

SHRJ247's avatar
SHRJ247
New Member
1 year ago
Solved

DAX formatting error - VALUE or FORMAT function recommended

I need help either effectively applying the FORMAT or VALUE commands vs something else if I have misunderstood the formatting error I have recieved on my DAX code (copied below)   Error recieved = ...
  • johnt75's avatar
    1 year ago

    The issue is the "&". A single ampersand like you have here is the string concatenation operator, you want "&&" which is a logical and.

  • Nasif_Azam's avatar
    1 year ago

    Hey SHRJ247 ,

    You're getting this error:  “DAX comparison operations do not support comparing values of type Integer with values of type Text…”

    This occurs because of the & operator, which concatenates text it does not function as a logical AND (&&). DAX interprets S_RY & DOP < 42 as text concatenation (even though they’re numbers), and the resulting expression becomes semantically invalid.

     

    You likely meant to use the logical AND operator &&. So change this line:

    IF (AED_RY > S_RY & DOP < 42, S_RY, AED_RY)

    To:

    IF (AED_RY > S_RY && DOP < 42, S_RY, AED_RY)

     

    Final Corrected Code

    Draft =
    VAR S_RY = LOOKUPVALUE('Aims Calender'[Reporting Year], 'Aims Calender'[Date], Aims[StartDate])
    VAR AED_RY = RELATED('Aims Calender'[Reporting Year])
    VAR DOP = Aims[Days On Programme]
    RETURN
    IF (AED_RY > S_RY && DOP < 42, S_RY, AED_RY)

     

    If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.


    Best Regards,
    Nasif Azam