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

Average Spacing

Spoiler
Spoiler
 

date/timedate/timeHello, 

 

I am having problems calculating the average spacing between dates 

1 ACCEPTED SOLUTION

Hi,

 

Please take following steps:

1)Add an index column to the original table in Query Editor.

2)Try this column to combine date and time columns:

Date-Time = 'Table'[Date]+'Table'[Time]

3)Try this calcluated column:

Column =
DATEDIFF (
    CALCULATE (
        MAX ( 'Table'[Date-Time] ),
        FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 )
    ),
    'Table'[Date-Time],
    SECOND
)

4)The result shows:

1.PNG

See my attached pbix file.

 

Best Regards,

Giotto

 

View solution in original post

4 REPLIES 4
v-gizhi-msft
Community Support
Community Support

Hi,

 

Could you please explain more about your requirement?

You can share your expected result as a screenshot.

Expect your reply!

 

Best Regards,

Giotto

 

Anonymous
Not applicable

Hello, @parry2k , @v-gizhi-msft  

 

 I want to calculate the date difference (in minutes) between each date in the column shown.

 

For example:  

Date               Time           Results in seconds  

08/04/2020  15:52:20       

08/04/2020  15:52:20        0

08/04/2020  15:52:22        2

08/04/2020  15:22:24        2  

08/04/2020  15:24:00       96

09/04/2020  15:24:00        86 400      (24 hours in seconds)

09/04/2020  15:24:25        25

09/04/2020  15:25:25       60

09/04/2020  15:29:25       240

09/04/2020  15:29:25       0

 

Thank you in advance

Best, 

Mark

 

 

 

Hi,

 

Please take following steps:

1)Add an index column to the original table in Query Editor.

2)Try this column to combine date and time columns:

Date-Time = 'Table'[Date]+'Table'[Time]

3)Try this calcluated column:

Column =
DATEDIFF (
    CALCULATE (
        MAX ( 'Table'[Date-Time] ),
        FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 )
    ),
    'Table'[Date-Time],
    SECOND
)

4)The result shows:

1.PNG

See my attached pbix file.

 

Best Regards,

Giotto

 

parry2k
Super User
Super User

@Anonymous not fully clear what you are trying to do here. Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.