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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Magrfa
Frequent Visitor

Hierarchy on a duration, and duration if no end date

Sorry I am still new to Power BI

 

I have a column which is a duration. calculated from a Logon date/time colomn and a Logoff date/time column. (Logoff-Logon)

1. Is there a way that if there is no logoff value it will calculate to Now or today or a similar function.

2. I have added this to my visuals but would like this to have a hierachy like a date/time field, is there a way to achive this

some of the users have a duration in Days, some in Hours and some in Minuites so it would be great to be-able to dynamically change between these for the visuals

 

Below is a copy of the Data, PowerBI would not let me select a range to copy the datd so I had to provide it as an image

Magrfa_0-1666103281930.png

 

1 ACCEPTED SOLUTION
hokeson
Microsoft Employee
Microsoft Employee

create a new column where you enter the logoff value and when empty then now()

 

= Table.AddColumn(#"Renamed Columns", "Custom", each if [LogOff] = null then DateTime.LocalNow() else [LogOff])

 

to format duration output you can use the following guide

Calculate Duration in Days Hours Minutes and Seconds Dynamically in Power BI using DAX - RADACAD

hope it helps

 

View solution in original post

1 REPLY 1
hokeson
Microsoft Employee
Microsoft Employee

create a new column where you enter the logoff value and when empty then now()

 

= Table.AddColumn(#"Renamed Columns", "Custom", each if [LogOff] = null then DateTime.LocalNow() else [LogOff])

 

to format duration output you can use the following guide

Calculate Duration in Days Hours Minutes and Seconds Dynamically in Power BI using DAX - RADACAD

hope it helps

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors