Hi All,
I have a total duration column in Excel with values like these
| TotalDuration |
| 1h23m17s |
| 46m9s |
| 29s |
I need to separate the hours, minutes, seconds, and also get total duration in seconds. As you can see the format and delimiters vary, and there is no consistent length. So, a simple text to columns functions wouldn't work.
So I came with below formulae. B2 is the cell the value is present in.
| For extracting hour | IF(ISNUMBER(SEARCH("h",B2)),LEFT(B2,FIND("h",B2)-1),0) |
| For extracting minutes | IF(ISNUMBER(SEARCH("h",B2)),MID(LEFT(B2,FIND("m",B2)-1),FIND("h",B2)+1,LEN(B2)),IF(ISNUMBER(SEARCH("m",B2)),LEFT(B2,FIND("m",B2)-1),0)) |
| For extracting seconds | IF(ISNUMBER(SEARCH("m",B2)),MID(LEFT(B2,FIND("s",B2)-1),FIND("m",B2)+1,LEN(B2)),IF(ISNUMBER(SEARCH("s",B2)),LEFT(B2,FIND("s",B2)-1),0)) |
| Total Duration in Seconds | (IF(ISNUMBER(SEARCH("h",B3)),LEFT(B3,FIND("h",B3)-1),0))*3600+(IF(ISNUMBER(SEARCH("h",B3)),MID(LEFT(B3,FIND("m",B3)-1),FIND("h",B3)+1,LEN(B3)),IF(ISNUMBER(SEARCH("m",B3)),LEFT(B3,FIND("m",B3)-1),0)))*60+IF(ISNUMBER(SEARCH("m",B3)),MID(LEFT(B3,FIND("s",B3)-1),FIND("m",B3)+1,LEN(B3)),IF(ISNUMBER(SEARCH("s",B3)),LEFT(B3,FIND("s",B3)-1),0)) |
The above formulae check for values, adapt to varying delimiters, extract them if present or put in 0 if they don't.
I have about 7 columns like these, and would like to use alteryx to automate this but learned the excel formula doesn't translate to Alteryx as is.
Could anybody help with the best way in going about achieving my end goal? Wasn't sure if using the formula is the best way or if I have to look at regex. Eitherway, I would be new to both options. Any help would be appreciated!
Thank you!