Forum Discussion
bourne2000
4 years agoHelper V
Convert the column into duration - Throwing an error
Hi I have the below column I am trying to convert it into duration. Getting below error message Expression.Error: We couldn't parse the Duration literal. Details: 24:18:34 I c...
- 4 years ago
TheoC
4 years agoCommunity Champion
Hi bourne2000
Use the following Custom Column in Power Query:
try
let _arr = List.Transform(Text.Split([Duration],":"),each Number.FromText(_)) in #duration (0 , 0 , (if List.Count (_arr) = 3 then _arr{0} * 60 else 0 ) + _arr{1} , _arr{2}) otherwise null
This works well and no need for mucking around with additional columns, etc., nor new queries, just a Custom Column.
Once you add the above, you can then just select Duration from the drop down box.
All the best!
Theo
Source: https://community.powerbi.com/t5/Power-Query/Duration-greater-than-24-gives-error/td-p/1084539
AllisonKennedy
4 years agoCommunity Champion
If you're going to use the Custom #duration( ) function then no need for the if else:
try
let _arr = List.Transform(Text.Split([Duration],":"),each Number.FromText(_)) in
#duration (
0 , _arr{0} , _arr{1} , _arr{2}
)
otherwise null
- TheoC4 years agoCommunity Champion
That's a good pick up AllisonKennedy