Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ronniealfaro
New Member

Convert to string ( 10 days, 2 hours, 1 minute for example ) to only minutes

Hello all,

 

So my data source is giving a duration in the form of

 

4 hours 5 minutes

1 day 2 hours 1 minute

56 minutes

 

I was wondering how this could be transformed into a minutes only result, since i can have days, hours or minutes, I guess it can be done with Dax.

 

No, the data source can't be changed, at least not in time for some dashboards we need out.

 

Any idea on how to make this work??

 

Thanks in advance.

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @ronniealfaro,

 

You can achieve this via Power Query. Please add custom columns in Query Editor mode.

1.PNG

 

=if Text.PositionOf([Column1],"day") <0 then 0 else Number.FromText(Text.Start([Column1], Text.PositionOf([Column1],"day")))

=if Text.PositionOf([Column1],"hours") <0 then 0 else Number.FromText(Text.End(Text.Trim(Text.Start([Column1], Text.PositionOf([Column1],"hours"))),2))

=if Text.PositionOf([Column1],"minutes")<0 then 0 else Number.FromText(Text.End(Text.Trim(Text.Start([Column1], Text.PositionOf([Column1],"minutes"))),2))

=[day value]*24*60+[hour value]*60+[minute value]

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @ronniealfaro,

 

You can achieve this via Power Query. Please add custom columns in Query Editor mode.

1.PNG

 

=if Text.PositionOf([Column1],"day") <0 then 0 else Number.FromText(Text.Start([Column1], Text.PositionOf([Column1],"day")))

=if Text.PositionOf([Column1],"hours") <0 then 0 else Number.FromText(Text.End(Text.Trim(Text.Start([Column1], Text.PositionOf([Column1],"hours"))),2))

=if Text.PositionOf([Column1],"minutes")<0 then 0 else Number.FromText(Text.End(Text.Trim(Text.Start([Column1], Text.PositionOf([Column1],"minutes"))),2))

=[day value]*24*60+[hour value]*60+[minute value]

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you @v-yulgu-msft

It did the job

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.