Forum Discussion

sacheu's avatar
sacheu
Icon for Microsoft Employee rankMicrosoft Employee
5 years ago
Solved

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', 

 

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'?

 

  • 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.

     

     

1 Reply

  • v-yingjl's avatar
    v-yingjl
    Icon for Community Support rankCommunity 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.