Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
blckbrd
Contributor
Contributor

Converting string time to numbers with expression editor

Hello, I'm new to Qlik sense and I have run into a problem with a dataset I'm using.

The dataset is about movies and I would like to convert the runtime to minutes. The runtime is currently formatted as '1 hr 30 min' but I would like it to be '90'.

Labels (2)
1 Solution

Accepted Solutions
MarcoWedel

some solutions might be:

 

MarcoWedel_0-1649504573001.png

 

tabRuntimes:
Load *,
     Interval#(Replace(Replace(RuntimeTxt,'hr',':'),'min',''),'h : mm')*1440 as Runtime,
     Evaluate(Replace(SubField(RuntimeTxt,'min',1),'hr','*60+')) as Runtime2
Inline [
RuntimeTxt
1 hr 30 min
1 hr 16 min
3 hr 21 min
];

 

hope this helps

Marco

View solution in original post

3 Replies
MarcoWedel

Is this the only format or might there be others as well?
What if the runtime is shorter than one hour, or longer than a day for that matter?

blckbrd
Contributor
Contributor
Author

This is the only format. The shortest runtime in the dataset is 1h 16 min and the longest in 3hr 21min.

MarcoWedel

some solutions might be:

 

MarcoWedel_0-1649504573001.png

 

tabRuntimes:
Load *,
     Interval#(Replace(Replace(RuntimeTxt,'hr',':'),'min',''),'h : mm')*1440 as Runtime,
     Evaluate(Replace(SubField(RuntimeTxt,'min',1),'hr','*60+')) as Runtime2
Inline [
RuntimeTxt
1 hr 30 min
1 hr 16 min
3 hr 21 min
];

 

hope this helps

Marco