Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

DAX, nested if function with not supporting dates and text comparison error

hello there, 
I'm trying to add a new column with nested if functions but im getting this error : DAX comparison operations do not support comparing values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values. 
I verified each of my column used in the function and they are all either dates or Whole number format, is it because its 2 different format? and if so how would I change the date format to whole numbers to be able to have the number of days between 2 dates when my conditons are met.

Here is my function : 


delai CSR = IF(
InvestigationCompteur[RMBECrééLe]<> "",
TRUNC(
InvestigationCompteur[RMBECrééLe]-InvestigationCompteur[DateIntitiation],0),
IF(
InvestigationCompteur[MT20 requis (INT)]="2",
TRUNC(
InvestigationCompteur[DateÉtat]-InvestigationCompteur[DateIntitiation],0),
IF(
InvestigationCompteur[MT20DateRV]="",
TRUNC(
NOW()-InvestigationCompteur[DateIntitiation],0),
TRUNC(
InvestigationCompteur[MT20DateRV]-InvestigationCompteur[DateIntitiation],0
))))
 
 
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hello,

     

    I'm thinking that this part of your switch is where the error could be:

    IF(
    InvestigationCompteur[MT20DateRV]="",
    TRUNC(
    NOW()-InvestigationCompteur[DateIntitiation],0),

    If InvestigationCompteur[MT20DateRV] is a DATE value, you're trying to see if it is equal to "", which is a string value. If you're trying to say, "if [MT20DateRV] is null do this", try setting it = to BLANK() like below:

    IF(
    InvestigationCompteur[MT20DateRV] = BLANK(),
    TRUNC(
    NOW()-InvestigationCompteur[DateIntitiation],0),




2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello,

     

    I'm thinking that this part of your switch is where the error could be:

    IF(
    InvestigationCompteur[MT20DateRV]="",
    TRUNC(
    NOW()-InvestigationCompteur[DateIntitiation],0),

    If InvestigationCompteur[MT20DateRV] is a DATE value, you're trying to see if it is equal to "", which is a string value. If you're trying to say, "if [MT20DateRV] is null do this", try setting it = to BLANK() like below:

    IF(
    InvestigationCompteur[MT20DateRV] = BLANK(),
    TRUNC(
    NOW()-InvestigationCompteur[DateIntitiation],0),




  • dax's avatar
    dax
    Community Support

    Hi Anonymous ,

    It seems to be type problem, you said that type is whole value or date, I think you need to change expression like below

    InvestigationCompteur[RMBECrééLe]<> blank()
    InvestigationCompteur[MT20 requis (INT)]=2

    The "" represent text, you need to modify it to see whteher it work or not.

     

    Best Regards,
    Zoe Zhi

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