Forum Discussion
Converting to mm:ss
I looked at this post which explaing about conversion from decimal to hh:ss. I tried to adapt it to my needs. My decimal number is day and according to google i need to multiply it by 86400 to get it into seconds in order to be able to use this code.
I can see that it is giving me conversion error but I have no idea which line of code this is. How would I determine where is the error from this.
- Anonymous2 years ago
Hi stribor45 ,
You can try the following dax:
Column = VAR time = 'Table'[Day] VAR hours = ROUNDDOWN(24 * time , 0) VAR H_rem = 24 * time - ROUNDDOWN(24 * time , 0) VAR minutes = ROUNDDOWN(60 * H_rem , 0) VAR M_rem = 60 * H_rem - ROUNDDOWN(60 * H_rem , 0) VAR seconds = ROUND(60 * M_rem , 0) Return TIME(hours,minutes,seconds)I show hh:mm:ss in Power Query, to Power BI Desktop it shows up fine and cannot reproduce your scenario:
Is your Power BI Desktop the latest version, if not, upgrade to the latest version in the link below:
Download Power BI Desktop from Official Microsoft Download Center
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
2 Replies
- stribor45
Post Prodigy
in power query my data is shown as duration but once it is loaded into the model it is showing as a decimal number. Thats why I am trying to use this code above. Is there an easier way to show this decimal number as hh:mm:ss?
- AnonymousNot applicable
Hi stribor45 ,
You can try the following dax:
Column = VAR time = 'Table'[Day] VAR hours = ROUNDDOWN(24 * time , 0) VAR H_rem = 24 * time - ROUNDDOWN(24 * time , 0) VAR minutes = ROUNDDOWN(60 * H_rem , 0) VAR M_rem = 60 * H_rem - ROUNDDOWN(60 * H_rem , 0) VAR seconds = ROUND(60 * M_rem , 0) Return TIME(hours,minutes,seconds)I show hh:mm:ss in Power Query, to Power BI Desktop it shows up fine and cannot reproduce your scenario:
Is your Power BI Desktop the latest version, if not, upgrade to the latest version in the link below:
Download Power BI Desktop from Official Microsoft Download Center
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly