Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Calculating difference between two date columns

Hi all,

 

I'm trying to calculate the difference between two date columns, however I'm running into some difficulty. The two columns, startdate and enddate, are coming from a Dim table, so if I try to create a measure using DATEDIFF it won't allow me to select from them, it will only allow me to select from other measures created. Is there a way around this?

 

I am unable to create a new calculated column as this data is coming straight from SSAS.

 

Thanks,

Aaron 

  • Hi Anonymous ,

     

    Based on your description, I have created a simple sample:

    Please try:

    Diff = DATEDIFF(MAX('Dim'[startdate]),MAX('Dim'[enddate]),DAY)

    Output:

    Kind Regards,

    Bubble

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

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous Try something like MyDiff Measure = MAX('Table1'[EndDate]) - MAX('Table1'[StartDate]) * 1.

     

     

  • Hi Anonymous ,

     

    Based on your description, I have created a simple sample:

    Please try:

    Diff = DATEDIFF(MAX('Dim'[startdate]),MAX('Dim'[enddate]),DAY)

    Output:

    Kind Regards,

    Bubble

    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

      This worked! Thank you Bubble, much appreciated