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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Rigoleto
Helper II
Helper II

Calculate total elapsed minutes

I need help, I am really new in the Power BI, this is my question:

 

I need to do this scenario:

1. Set up my current datetime  to 7:00 am, for instance 20180614 7:00 am(Current time is 15:16)

2. Use the current date time 20180614 15:16 with the previous item to get the total minutes lapsed from 7:00 am to 15:16 pm

 

I really apreciate your help with this issue

 

🙂

1 ACCEPTED SOLUTION
ChrisMendoza
Resident Rockstar
Resident Rockstar

Hello @Rigoleto,

 

At first glance I thought this was a simple problem however the issue for me was your datetime format beginning with '20180614 '.

 

The Query Editor should help you solve this:

 

let
    Source = /* I used an Excel file with a table named 'TableName' */
    TableName_Table = Source{[Item="TableName",Kind="Table"]}[Data],
    /* Step 1 Replace the " " with 'T' to fulfill YYYYMMDDThh:mm:ss.nnnnnnn format requirement for DateTime.FromText ( ) */
        #"Replaced Value" = Table.ReplaceValue(TableName_Table," ","T",Replacer.ReplaceText,{"StartDatetime"}),
    /* Step 2 use DateTime.FromText ( ) */
	#"Added Custom" = Table.AddColumn(#"Replaced Value", "Custom", each DateTime.FromText([StartDatetime])),
    /* Step 3 get the current time */
	#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each DateTime.LocalNow()),
    /* Step 4 if it didn't recognize the Type, change the type to datetime */
	#"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"Custom.1", type datetime}, {"Custom", type datetime}}),
    /* Step 5 get the duration in minutes */
	#"Added Custom2" = Table.AddColumn(#"Changed Type", "Custom.2", each Duration.TotalMinutes([Custom.1]-[Custom])),
    /* Step 6 change the type */
	#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom2",{{"Custom.2", type number}})
in
    #"Changed Type1"

1.PNG

 

 

 

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

2 REPLIES 2
ChrisMendoza
Resident Rockstar
Resident Rockstar

Hello @Rigoleto,

 

At first glance I thought this was a simple problem however the issue for me was your datetime format beginning with '20180614 '.

 

The Query Editor should help you solve this:

 

let
    Source = /* I used an Excel file with a table named 'TableName' */
    TableName_Table = Source{[Item="TableName",Kind="Table"]}[Data],
    /* Step 1 Replace the " " with 'T' to fulfill YYYYMMDDThh:mm:ss.nnnnnnn format requirement for DateTime.FromText ( ) */
        #"Replaced Value" = Table.ReplaceValue(TableName_Table," ","T",Replacer.ReplaceText,{"StartDatetime"}),
    /* Step 2 use DateTime.FromText ( ) */
	#"Added Custom" = Table.AddColumn(#"Replaced Value", "Custom", each DateTime.FromText([StartDatetime])),
    /* Step 3 get the current time */
	#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each DateTime.LocalNow()),
    /* Step 4 if it didn't recognize the Type, change the type to datetime */
	#"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"Custom.1", type datetime}, {"Custom", type datetime}}),
    /* Step 5 get the duration in minutes */
	#"Added Custom2" = Table.AddColumn(#"Changed Type", "Custom.2", each Duration.TotalMinutes([Custom.1]-[Custom])),
    /* Step 6 change the type */
	#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom2",{{"Custom.2", type number}})
in
    #"Changed Type1"

1.PNG

 

 

 

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Thanks!!!!!

 

I have used the logic and it is running as my expectation 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.