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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors