Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anilkumardoddi
New Member

Date Difference between 2 dates from 2 rows

Hi All,

ProgramMilestoneDatesDelay days
KL-41A006-Nov-25 
KL-41P117-Nov-25 
DH-05A022-Jan-25 
DH-05P129-Aug-25 
Ak-220A010-Aug-23 
Ak-220P103-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 

2 ACCEPTED SOLUTIONS
Shahid12523
Community Champion
Community 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.

Shahed Shaikh

View solution in original post

bhanu_gautam
Super User
Super 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)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

8 REPLIES 8
bhanu_gautam
Super User
Super 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)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thank you 🙂

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.

Hi @Anilkumardoddi ,

Can you please confirm whether the issue is sorted or not.

Thank you.

Hi Menakakota, the above information was very helpful. I was able to resolve my issue. Thanks a lot, everyone!

Hi @Anilkumardoddi ,

Thank you for the update. Can you please mark the solution as "Accept as Solution", This would be helpful for other members who may encounter similar issues. 

Thank you for your understanding and assistance. 

Shahid12523
Community Champion
Community 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.

Shahed Shaikh

Thanks, this helps 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.