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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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