Forum Discussion

gablewithbird's avatar
gablewithbird
Frequent Visitor
7 years ago
Solved

IF statement for identifying data type.

A very dumb question.

Why PowerBI couldn't return order dates when my condition is true?

 

 

 

 

 

 

 

  • The 'IF' statement has two possible outcomes.  They must both be of the same data type.

  • Hey,

     

    this is due to the fact, IF can not return values of different data types, your statement will return a date (Ordered Date) or a string "".

    You can use this instead:

    Column = IF('Table1'[CheckCondition] = "Calendar" , 'Table1'[Ordered Date] , BLANK())

    Instead of returning an empty string "", return BLANK(), if the IF condition equals to FALSE

     

    Hopefully this is what you are looking for.

     

    Regards,

    Tom

5 Replies

  • HotChilli's avatar
    HotChilli
    Community Champion

    The 'IF' statement has two possible outcomes.  They must both be of the same data type.

    • gablewithbird's avatar
      gablewithbird
      Frequent Visitor

      HotChilli 

      Awesome and interesting.

      I learned that using BLANK(), instead of "" fixes the issue.

      Cmcmahan 

      it's not output from an expression. it's just fixed text. 

       

      thanks for your help.

       

       

  • Cmcmahan's avatar
    Cmcmahan
    Resident Rockstar

    What is the expression used to caclulate the SLArule.Calendar/Business column?

  • Hey,

     

    this is due to the fact, IF can not return values of different data types, your statement will return a date (Ordered Date) or a string "".

    You can use this instead:

    Column = IF('Table1'[CheckCondition] = "Calendar" , 'Table1'[Ordered Date] , BLANK())

    Instead of returning an empty string "", return BLANK(), if the IF condition equals to FALSE

     

    Hopefully this is what you are looking for.

     

    Regards,

    Tom