Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Measure with DateAdd returns NaN

Hi there,

I`m struggling with the measure dateAdd which delivers NaN, which I don´t understand.

The value in the table which I am searching for looks like this:

The measure which I am using is

ValuePrevMonth = (CALCULATE([Price], DATEADD(Table[Date],-1, MONTH)))
 
when put next to each other the first entry is there, but the second is shown as NaN

 

Actually, my understanding was that at least 0 should be returned. There is no calculation or division through zero, so why NaN?

In case of the dateAdd function: which key is used to do a lookup? Do I need an extra mapping to a calendar table?

 

Thanks in advance for any feedback.

 

  • Anonymous , if there is only price and valueprevmonth, there is no way of distinction. For each product the valueprevMonth will be different. If delivery name is added to table visual, the measure will look like this

     

     

7 Replies

  • Anonymous , If [price] is a column, then try changing the dax to 

     

    ValuePrevMonth = (CALCULATE(sum('Table'[Price])DATEADD('Table'[Date],-1MONTH)))

     

    Thank you

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks, but price is already a measure with sum(table[price]), my fault, I should have added this as information.

      • ChiragGarg2512's avatar
        ChiragGarg2512
        Icon for Solution Sage rankSolution Sage

        Anonymous , Check the data type of date column. The dax seems to work fine