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
Anonymous
Not applicable

Find date between two identical values in another column

Hey

I want to find the difference in time (column: "occurred_at") between two identical numbers (column: "index") and print this in a new column.
An example is given below.

occurred_atindextime_diff
10-01-2023 09:00:00    11 day
09-01-2023 09:00:00    1 (blank)
08-01-2023 09:00:00    22 days
07-01-2023 09:00:00    32 days
06-01-2023 09:00:00    2(blank)
05-01-2023 09:00:00    3 (blank)


I really appreciate any help you can provide.

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @Anonymous 

See it all at work in the attached file. Create a calculated column in your table:

 

time_diff = 
VAR min_ = CALCULATE(MIN(Table1[occurred_at]), ALLEXCEPT(Table1, Table1[index]))
VAR max_ = CALCULATE(MAX(Table1[occurred_at]), ALLEXCEPT(Table1, Table1[index]))
RETURN
IF(max_ = Table1[occurred_at], DATEDIFF(min_, max_, DAY))

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

5 REPLIES 5
AlB
Community Champion
Community Champion

Hi @Anonymous 

See it all at work in the attached file. Create a calculated column in your table:

 

time_diff = 
VAR min_ = CALCULATE(MIN(Table1[occurred_at]), ALLEXCEPT(Table1, Table1[index]))
VAR max_ = CALCULATE(MAX(Table1[occurred_at]), ALLEXCEPT(Table1, Table1[index]))
RETURN
IF(max_ = Table1[occurred_at], DATEDIFF(min_, max_, DAY))

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Idrissshatila
Super User
Super User

Hello @Anonymous ,

 

If you have two date columns you can use datediff function to see the difference betweern the two dates.

 

To do so you add a new column with the following measure

 

Diff =
DATEDIFF ( Date1, Date2, DAY )

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

 

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Anonymous
Not applicable

I will clarify the question.
How do I know when to take the difference? 

@Anonymous,

Do you mean that you don't want to see blank ?

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

 

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Anonymous
Not applicable

I want to find the time difference between two identical numbers in the column "index". E.g. finding the time difference between the index-number 2 is 2 days (see table).

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors