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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
admin_xlsior
Post Prodigy
Post Prodigy

Direct Query : Transform Integer Value to Time datatype and time format

Hi,

 

I have a fact table which coming from Direct Query, in which it supposed to be an integer contain second (time)

 

Sample as below: (the 1st 2 column is the original value from SQL table, and the rest is just after SQL function Convert which I'm using for checking :

STARTTIMESTOPTIMESTARTTIMESTOPTIME
85105023:38:250:00:00
85105023:38:250:00:00
85105023:38:250:00:00
000:00:000:00:00
000:00:000:00:00
000:00:000:00:00
000:00:000:00:00
000:00:000:00:00
000:00:000:00:00
668306697318:33:5018:36:13
66830018:33:500:00:00
668306697318:33:5018:36:13
670206720018:37:0018:40:00
67020018:37:000:00:00
683296834218:58:4918:59:02
68329018:58:490:00:00
683296834218:58:4918:59:02
670206720018:37:0018:40:00

 

The way I import is not with the last 2 column, so it is just the 1st 2 column, the integer value to Power BI. And in Edit Query, when I change the Data type to Time, it give me error.

 

The last 2 column is the way I want Power BI to display.

 

Please help,

 

Thanks,

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @admin_xlsior ,

 

You can use following calculate column to achieve your requirement:

STOPTIME = 
var _hour=INT([STOPTIME]/3600)
var _minute=MOD([STOPTIME],3600)/60
var _second=MOD(MOD([STOPTIME],3600),60)
return
TIME(_hour,_minute,_second)

STARTTIME = 
var _hour=INT([STARTTIME]/3600)
var _minute=MOD([STARTTIME],3600)/60
var _second=MOD(MOD([STARTTIME],3600),60)
return
TIME(_hour,_minute,_second)

Notice: above formula not works on value who greater than 24 hours.

 

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @admin_xlsior ,

 

You can use following calculate column to achieve your requirement:

STOPTIME = 
var _hour=INT([STOPTIME]/3600)
var _minute=MOD([STOPTIME],3600)/60
var _second=MOD(MOD([STOPTIME],3600),60)
return
TIME(_hour,_minute,_second)

STARTTIME = 
var _hour=INT([STARTTIME]/3600)
var _minute=MOD([STARTTIME],3600)/60
var _second=MOD(MOD([STARTTIME],3600),60)
return
TIME(_hour,_minute,_second)

Notice: above formula not works on value who greater than 24 hours.

 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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