Forum Discussion

haidong's avatar
haidong
New Member
6 years ago
Solved

DAX comparison operations do not support comparing values of type Text with values of type Integer

I got error message with this fomular :

 

if('GI_Yield Feb20'[Item_N]="no",'GI_Yield Feb20'[Qty in unit of entry]/2,'GI_Yield Feb20'[Qty in unit of entry]
 
I have confirmed the data type of[Item_N] is text , just can't figure why = " no" doesn't work. 
 
where should I check futher?
Can anyone help?
Thanks very much.
  • Hi haidong ,

     

    I think there may be spaces in the item_n column.

    You can try the DAX below:

    Column =
    IF (
        SEARCH ( "no", 'GI_Yield Feb20'[Item_N], 1, 0 ) > 0,
        'GI_Yield Feb20'[Qty in unit of entry] / 2,
        'GI_Yield Feb20'[Qty in unit of entry]
    )

     

    Best Regards,
    Liang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • az38's avatar
    az38
    Community Champion

    Hi haidong 

    First of all heck it in Power Query Editor mode (if available)

    or you can debug issue with ISTEXT() function

    The statement

    Column = ISTEXT('GI_Yield Feb20'[Item_N])

    should return you true if the field is exactly Text

  • Try like this nad check

     

    if('GI_Yield Feb20'[Item_N] & ""="no",'GI_Yield Feb20'[Qty in unit of entry]/2,'GI_Yield Feb20'[Qty in unit of entry]

     

    Make sure data type changed here

    • AteeqSundhu's avatar
      AteeqSundhu
      Frequent Visitor

      Hi

      i m trying to extract first X digits out of my ID column of data as

       

      Match-ID = IF('ATL-270524'[NTN-FBR] = 9, LEFT('ATL-270524'[NTN-FBR], 7), LEFT('ATL-270524'[NTN-FBR], 11))
      but this resulted in error as "DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values."
       
      basically the field "NTN-FBR" is having digits plus "-" dash in few cases that is why i've kept data type of this field as "TEXT"
       
      kindly guide ASAP.
  • V-lianl-msft's avatar
    V-lianl-msft
    Community Support

    Hi haidong ,

     

    I think there may be spaces in the item_n column.

    You can try the DAX below:

    Column =
    IF (
        SEARCH ( "no", 'GI_Yield Feb20'[Item_N], 1, 0 ) > 0,
        'GI_Yield Feb20'[Qty in unit of entry] / 2,
        'GI_Yield Feb20'[Qty in unit of entry]
    )

     

    Best Regards,
    Liang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.