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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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