Forum Discussion
Date Difference between 2 dates from 2 rows
- 11 months ago
Option 1: Calculated Column
If you want the delay at the program level, create a calculated column in your table:
Delay Days =
VAR ProgramID = Table1[Program]
VAR A0Date =
CALCULATE (
MIN ( Table1[Dates] ),
Table1[Program] = ProgramID,
Table1[Milestone] = "A0"
)
VAR P1Date =
CALCULATE (
MIN ( Table1[Dates] ),
Table1[Program] = ProgramID,
Table1[Milestone] = "P1"
)
RETURN
DATEDIFF ( A0Date, P1Date, DAY )
This will give you the days difference for each program.Option 2: Measure
If you only need it as a measure (e.g., in a table visual with Program):
Delay Days =
VAR A0Date =
CALCULATE (
MIN ( Table1[Dates] ),
Table1[Milestone] = "A0"
)
VAR P1Date =
CALCULATE (
MIN ( Table1[Dates] ),
Table1[Milestone] = "P1"
)
RETURN
DATEDIFF ( A0Date, P1Date, DAY )
When you put this measure in a table visual with Program, it will show the delay. - 11 months ago
Anilkumardoddi , Create a calculated column
DelayDays =
VAR A0Date = CALCULATE(
MAX('YourTable'[Dates]),
'YourTable'[Milestone] = "A0"
)
VAR P1Date = CALCULATE(
MAX('YourTable'[Dates]),
'YourTable'[Milestone] = "P1"
)
RETURN
DATEDIFF(A0Date, P1Date, DAY)
Option 1: Calculated Column
If you want the delay at the program level, create a calculated column in your table:
Delay Days =
VAR ProgramID = Table1[Program]
VAR A0Date =
CALCULATE (
MIN ( Table1[Dates] ),
Table1[Program] = ProgramID,
Table1[Milestone] = "A0"
)
VAR P1Date =
CALCULATE (
MIN ( Table1[Dates] ),
Table1[Program] = ProgramID,
Table1[Milestone] = "P1"
)
RETURN
DATEDIFF ( A0Date, P1Date, DAY )
This will give you the days difference for each program.
Option 2: Measure
If you only need it as a measure (e.g., in a table visual with Program):
Delay Days =
VAR A0Date =
CALCULATE (
MIN ( Table1[Dates] ),
Table1[Milestone] = "A0"
)
VAR P1Date =
CALCULATE (
MIN ( Table1[Dates] ),
Table1[Milestone] = "P1"
)
RETURN
DATEDIFF ( A0Date, P1Date, DAY )
When you put this measure in a table visual with Program, it will show the delay.
Thanks, this helps 🙂