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
sacheu
Employee
Employee

How to convert a column to duration in 'Data' view?

Hi,

In the Power Query Editor view (right click a table and select 'Edit Query'), I can select 'Data Type' of my column to 'Duration', 

sacheu_0-1613538840509.png

 

But after 'close & apply', that column become 'Decimal number', I can't select 'Duration' from the Date Type'. And when I create a table to show values of that column, it also shows up as Decimal number.

 

So how can I set the data type of this column to 'Duration'?

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @sacheu ,

It is by design in power bi.

Power Query provides a set of contextual transformations and options based on the data type of the column. These transformations and options occur throughout the Power Query interface, such as on the Transform and Add column tabs and the smart filter options.

Duration:

Represents a length of time, which is converted into a Decimal Number type when loaded into the model. As a Decimal Number type, it can be added or subtracted from a Date/Time field with correct results. 

 

The data types in the model and power query are different, please refer:

  1. Data types in Power Query 
  2. Data types in Power BI Desktop 

 

About Duration type in power query, you can refer this simliar issue: Purpose of "Duration" datatype in Power Query 

 

If you want to calculate some diff between dates, you can use Datediff() function.

 

Best Regards,
Community Support Team _ Yingjie Li
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

1 REPLY 1
v-yingjl
Community Support
Community Support

Hi @sacheu ,

It is by design in power bi.

Power Query provides a set of contextual transformations and options based on the data type of the column. These transformations and options occur throughout the Power Query interface, such as on the Transform and Add column tabs and the smart filter options.

Duration:

Represents a length of time, which is converted into a Decimal Number type when loaded into the model. As a Decimal Number type, it can be added or subtracted from a Date/Time field with correct results. 

 

The data types in the model and power query are different, please refer:

  1. Data types in Power Query 
  2. Data types in Power BI Desktop 

 

About Duration type in power query, you can refer this simliar issue: Purpose of "Duration" datatype in Power Query 

 

If you want to calculate some diff between dates, you can use Datediff() function.

 

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

 

 

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.