Forum Discussion
mblydt-hansen
8 years agoFrequent Visitor
Date difference between values in same column
Hi everyone! I'm still learning DAX and I was wondering if the collective minds of this forum could help me out with coding a custom column that I've been having difficulty with. I feel like my i...
- 8 years ago
You could use this calculated column
Column = VAR temp = TOPN ( 1, FILTER ( Table1, Table1[Patient ID] = EARLIER ( Table1[Patient ID] ) && Table1[Date of Visit] < EARLIER ( Table1[Date of Visit] ) ), [Date of Visit], DESC ) RETURN DATEDIFF ( MINX ( temp, [Date of Visit] ), Table1[Date of Visit], DAY )
Zubair_Muhammad
8 years agoCommunity Champion
You could use this calculated column
Column =
VAR temp =
TOPN (
1,
FILTER (
Table1,
Table1[Patient ID] = EARLIER ( Table1[Patient ID] )
&& Table1[Date of Visit] < EARLIER ( Table1[Date of Visit] )
),
[Date of Visit], DESC
)
RETURN
DATEDIFF ( MINX ( temp, [Date of Visit] ), Table1[Date of Visit], DAY )Anonymous
5 years agoNot applicable
Hi,
I have a similar problem. I have 3 columns, one with different products IDs, one with different status and one with dates, which replicate lines adding one day until the product status changes. So I want to calculate the difference between the max date and min date for determined product ID and status.
I applied something similar:
Column =
VAR temp =
TOPN (
1,
FILTER (
Teste,
Teste[Work Item Id] = EARLIER ( Teste[Work Item Id] ) && Teste[State] = EARLIER ( Teste[State] )
&& Teste[Date] < EARLIER ( Teste[Date] )
),
[Date], DESC
)
RETURN
DATEDIFF ( MINX ( temp, [Date] ), Teste[Date], DAY )
However, it does not work. Could you please help me?
Thank you!