Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

DATEDIFF ERROR

Hi Community,

 

Anyone knows why I am getting the below error? 

I have tried multiple versions of this measure, however none were successful. 

I want to get the number of months between those two dates, for eg:

Date Debut Effective - 01/01/2019

Date Fin Effective - 31/05/2019

M_S06 Expected Result = 5

 

6 Replies

  • Hi Anonymous ,

     

    The issue here is the order of your values within the CALCULATE.

     

    CALCULATE formula is composed by [Expression, filter1, filter 2,...] so your first value in the CALCULATE must be the difference of dates and not the ALLSELECTED since this last one is for filtering purposes and not calculation.

     

    Redo your calculation to:

    M_S06 =
    CALCULATE (
        DATEDIFF (
            t_Mission[Date Début Effective];
            t_Mission[Date Fin Effective];
            MONTH
        );
        ALLSELECTED ( t_missions )
    )

    Regards,

    MFelix

    • Anonymous's avatar
      Anonymous
      Not applicable

      Apparentely I cannot perform the calculation.

      Can you please explain me why the columns aren't available and only measures that I have in the model show up when constructing this formula? 

       

      Thank you!

      Kind Regards

       

      • MFelix's avatar
        MFelix
        Super User

        Hi Anonymous ,

         

        you are creating a measure or a column?

         

        Regards,

        MFelix