Forum Discussion
Calculated Column Get Days Between Max Date And Date
Hi,
Using PBID (March, 2024)
I created a measure to get max date from a column - works as expected
I added a calculated column to compare the measure to the order date in each row - but this is returning zero
Days From Max Date =
DATEDIFF( Data[Date], [Max Date], DAY )
What am I doing wrong?
Thanks,
-w
- Anonymous2 years ago
Hi tecumseh ,
I create a table as you mentioned.
Then I create a calculated column named MaxDate.
MaxDate = MAX('Table'[Date])Also I create another calculated column.
Column = DATEDIFF('Table'[Date],'Table'[MaxDate],DAY)I think the reason you're getting 0 should be that you're using Measure when calculating the max dates, so it's returning the maximum value for each row of dates, which is going to give you 0 when subtracted, but you can avoid that if you use a calculated column.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- amitchandakSuper User
tecumseh , if you are trying to create a column when Max Date is Measure. You can not use a measure or slicer value in a column
Create a measure like
Averagex(data,DATEDIFF( Data[Date], [Max Date], DAY ))
- tecumsehResolver III
Thanks amitchandak
I need a calculated column. My end goal is to have something I can filter for <= 6 (0 - 6) Or the most recent 7 days. Today function seems to be problematic when refreshing in the Service not returning expected results due to time zones etc....
Thanks,-w
- AnonymousNot applicable
Hi tecumseh ,
I create a table as you mentioned.
Then I create a calculated column named MaxDate.
MaxDate = MAX('Table'[Date])Also I create another calculated column.
Column = DATEDIFF('Table'[Date],'Table'[MaxDate],DAY)I think the reason you're getting 0 should be that you're using Measure when calculating the max dates, so it's returning the maximum value for each row of dates, which is going to give you 0 when subtracted, but you can avoid that if you use a calculated column.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.