Forum Discussion

PBandI's avatar
PBandI
Frequent Visitor
2 years ago
Solved

Calculated Column not returning all correct values

Hi,

 

I created a calculated column that is taking the data from the "Wholesale Ship Date" column and adding 5 days to it: 

 

_Due Date = DATEADD('Wholesale | Retail'[Wholesale Ship Date], 5, DAY)
 
As you can see in the screenshot below, it is correctly working for some dates but not all. If I change the number of intervals to 7 or 21 for example, the amount of values in the _Due Date column change as well. Eventually this number of intervals will be driven by another measure, so I would appreciate any advice on how to fix this, thanks!

 

 

  • I figured out the solution. The value that the measure returns using the DATEADD function must exist in the same column (in this case Wholesale Ship Date) which isn't always true. I just added +5 to my Wholesale ship date column and it solved my issue. 

3 Replies

  • Hmm i would check if your 'Wholesale | Retail' table actually has a value that is 5 days before. I.e is there actually a 5/26/2022 in the dataset? how about 6/25/22? If not, then that would be why your formula is returning blanks - it can't create a date that doesn't exist in the dataset. 
    To fix it, you can create a date table (which contains every single date) and use that in your calculations instead.

    • PBandI's avatar
      PBandI
      Frequent Visitor

      The column should be adding 5 days to the "Wholesale Ship Date" column so why would it need to look and see if there is a value 5 days before? If I'm understanding correctly I just thought there would need to be a date in that column and then the measure would compute 5 days after that date and put that value in the new calculated column. I also currently have a date table that is connected to my "Wholesale | Retail" table but when I create the measure in the date table I still recieve blanks. Here is a new sample using the same measure but created within the date table:

       

  • PBandI's avatar
    PBandI
    Frequent Visitor

    I figured out the solution. The value that the measure returns using the DATEADD function must exist in the same column (in this case Wholesale Ship Date) which isn't always true. I just added +5 to my Wholesale ship date column and it solved my issue.