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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mifrasmm
Helper I
Helper I

Calculate Time to Current Time ( DAX )

Hi 

 

I need to create DAX measurement to calculate the timing ( Timer)  from Issued time to current time.

 

 

time.png

 

 

1 ACCEPTED SOLUTION
Phil_Seamark
Employee
Employee

Hi @mifrasmm

 

The DATEDIFF function will return a number based on the difference between two times in your interval of choice.  In the below example it returns the number of Seconds, but you can chose MINUTES, HOURS, DAYS etc.

 

NOW() returns the current time to the second.

 

Seconds = DATEDIFF([Column1],NOW(),SECOND)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

5 REPLIES 5
tringuyenminh92
Memorable Member
Memorable Member

Hi @mifrasmm,

 

You could try with DATEDIFF method with interval is second. after that convert to format you want: hh:mm:ss by topic

 

Create calculated column:

 

Duration in second = DATEDIFF(Sheet1[ISSUED_DATE],NOW(),SECOND)

Format your timing:

 

Timer = RIGHT ( "0" & INT (Sheet1[Duration in second] / 3600 ), 2 )
    & ":"
    & RIGHT (
        "0"
            & INT ( (Sheet1[Duration in second] - INT (Sheet1[Duration in second]/ 3600 ) * 3600 ) / 60 ),
        2
    )
    & ":"
    & RIGHT ( "0" & MOD (Sheet1[Duration in second], 3600 ), 2 )

 

2017-04-25_12h51_35.png

 

Phil_Seamark
Employee
Employee

Hi @mifrasmm

 

The DATEDIFF function will return a number based on the difference between two times in your interval of choice.  In the below example it returns the number of Seconds, but you can chose MINUTES, HOURS, DAYS etc.

 

NOW() returns the current time to the second.

 

Seconds = DATEDIFF([Column1],NOW(),SECOND)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

@Phil_Seamark

Got it , its working is there any way i can make H:mm

@Phil_Seamark thanks for replying 

 

I thing sometinng worng , i tried as measure and new column 

 

Untitled.png

 

Hi @mifrasmm

 

Is Issued_date a column or a measure?


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors