Forum Discussion
Date Difference between 2 dates from 2 rows
Hi All,
| Program | Milestone | Dates | Delay days |
| KL-41 | A0 | 06-Nov-25 | |
| KL-41 | P1 | 17-Nov-25 | |
| DH-05 | A0 | 22-Jan-25 | |
| DH-05 | P1 | 29-Aug-25 | |
| Ak-220 | A0 | 10-Aug-23 | |
| Ak-220 | P1 | 03-Nov-25 |
In Power BI, I want to calculate the number of days between the P1 and A0 dates for each program.
For example:
For KL-41, the delay should be 11 days, which is the difference between (17-Nov-2025) β (06-Nov-2025).
Could you please guide me on how to achieve this in DAX?
Thanks in advance!
Bibiano_Geraldo rajendraongole1 Ritaf1983 danextian lbendlin Ritaf1983 bhanu_gautam
MohamedFowzan1
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.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)
8 Replies
- Shahid12523Community Champion
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.- AnilkumardoddiRegular Visitor
Thanks, this helps π
- bhanu_gautamSuper User
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)- AnilkumardoddiRegular Visitor
Thank you π
- v-menakakotaCommunity Support
Hi Anilkumardoddi ,
Thanks for reaching out to the Microsoft fabric community forum.I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. Weβre always here to support you.
Thank you.