Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
fpena
Contributor
Contributor

How can I create a calculated field that provides a "Duration (in hours)" field? The fields with data are four: START DATE, START TIME, END DATE, and

How can I create a calculated field in Qlik Sense that provides a "Duration (in hours)" field? The fields with data are four: START DATE, START TIME, END DATE, and END TIME.

Labels (1)
4 Replies
marcus_sommer

Try it with: interval((START DATE + START TIME) - (END DATE + END TIME), 'hh')

fpena
Contributor
Contributor
Author

Hi. Marcus. 

i concatenate the date and time

How can I calculate the duration between the end of the failure and the start of the failure?

fpena_0-1690576926405.png

 

 

Gabbar
Specialist
Specialist

As there is a possibility that duration might be more than 1 hour,
And if what you shared in Screenshot is your time format then try this:-

(Num(Timestamp#("Start Time",'DD-MM-YYYY hh:mm'))-Num(Timestamp#("End Time",'DD-MM-YYYY hh:mm')))*24

Now with this Decimal Digits Might be a little Higher But you can adjust those using num or in measure only.

marcus_sommer

It will work if the values are really dates and times respectively numeric values and not strings. Your values are left-aligned which is often a sign that they are strings. With functions like:

date#(YourField, FormatPattern)
time#(YourField, FormatPattern)

could you convert the values into numbers. Ideally you don't do it for the duration else within the first step in which these fields are loaded because you will always need numeric values to be able to calculate with them.