cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mifrasmm Regular Visitor
Regular Visitor

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

Accepted Solutions
Phil_Seamark Super Contributor
Super Contributor

Re: Calculate Time to Current Time ( DAX )

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!

5 REPLIES 5
Phil_Seamark Super Contributor
Super Contributor

Re: Calculate Time to Current Time ( DAX )

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!

mifrasmm Regular Visitor
Regular Visitor

Re: Calculate Time to Current Time ( DAX )

@Phil_Seamark thanks for replying 

 

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

 

Untitled.png

 

Phil_Seamark Super Contributor
Super Contributor

Re: Calculate Time to Current Time ( DAX )

Hi @mifrasmm

 

Is Issued_date a column or a measure?


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

Proud to be a Datanaut!

Highlighted
mifrasmm Regular Visitor
Regular Visitor

Re: Calculate Time to Current Time ( DAX )

@Phil_Seamark

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

tringuyenminh92 New Contributor
New Contributor

Re: Calculate Time to Current Time ( DAX )

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

 

Helpful resources

Announcements
Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Summit Australia 2019

Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

PBI Community Highlights

PBI Community Highlights

Check out what's new in the Power BI Community!

Top Ideas
Users Online
Currently online: 30 members 713 guests
Please welcome our newest community members: