Forum Discussion

appsac1's avatar
appsac1
Icon for Helper I rankHelper I
4 years ago

If statement error "Dax comparison operators do not support comparing values of type text

I am receiving an error on trying to create an IF statement:

Resoultion Time Status =
IF(
[Granulated] = "OPEN" , "OPEN",
IF(
[Granulated] <=1, "24 hours",
IF(
[Granulated] <=2, "48 hours",
IF(
[Granulated] <=3, "72 hours",
IF(
[Granulated] <=4, "96 hours",
">5 days")))))
 
Any help with this would be of really appreciated.

12 Replies

  • appsac1 

    we can only have one type for one column. So we can't have text which is Open and number which are 1,2,3,4.

     

    may be you can try this:

     

    Resoultion Time Status =
    IF(
    [Granulated] = "OPEN" , "OPEN",
    IF(
    [Granulated] *1<=1 ."24 hours",
    IF(
    [Granulated] *1<=2, "48 hours",
    IF(
    [Granulated] *1<=3, "72 hours",
    IF(
    [Granulated] *1<=4, "96 hours",
    ">5 days")))))
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you so much it worked, could you explain the logic behind adding [Granulated] *1?

      • Anonymous's avatar
        Anonymous
        Not applicable

        I tried adding it to the table visual, but it only gives me two column fields "open" and "24 hours" as below:

         

         

  • v-zhangti's avatar
    v-zhangti
    Icon for Community Support rankCommunity Support

    Hi, appsac1 

     

    You can try the following methods.

    Resoultion Time Status = 
    IF(
    [Granulated] = "OPEN" , "OPEN",
    IF(
    VALUE([Granulated]) <=1, "24 hours",
    IF(
    VALUE([Granulated])<=2, "48 hours",
    IF(
    VALUE([Granulated])<=3, "72 hours",
    IF(
    VALUE([Granulated]) <=4, "96 hours",
    ">5 days")))))

    Is this the output you expect?

     

    Best Regards,

    Community Support Team _Charlotte

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

      • Anonymous's avatar
        Anonymous
        Not applicable

        I fixed this temporarily by replacing open in the Granulated formulae by 0
        Old - Granulated = IF(ISBLANK('April Tickets'[Resolved time].[Date]),FORMAT( "open" , ([Resolved time].[Date] - [Created time].[Date])*1.))

        New - 

        Granulated = IF(ISBLANK('April Tickets'[Resolved time].[Date]), 0 , DATEDIFF('April Tickets'[Created time],'April Tickets'[Resolved time],DAY))
         
        But I want open and not o to show in my table and I am unable to find a way to have both text and int. The format option isn't working.
    • Anonymous's avatar
      Anonymous
      Not applicable

      Sure, below is the measure code

      Granulated = IF(ISBLANK('April Tickets'[Resolved time].[Date]),FORMAT( "open" , ([Resolved time].[Date] - [Created time].[Date])*1.))