MarcelBeug's avatar
MarcelBeug
Community Champion
9 years ago
Status:
Done

Erroneous code generated for calculating Age for datetimezone data

Issue moved from the old issue site.

 

In Power Query - Edit queries you can select a column with data type date/time/timezone and then choose for Transform - Date - Age.

 

This will generate code like:

 

= Table.TransformColumns(SampleData,{{"DateTimeZone1", each DateTime.LocalNow() - _, type duration}})

 

which will generate errors due to different data types.

 

My suggestion would be
either not allow Age calculation for date/time/timezone data,
or have working code generated like:

 

= Table.TransformColumns(SampleData,{{"DateTimeZone1", each DateTimeZone.From(DateTime.LocalNow()) - _, type duration}})

4 Comments

  • v-haibl-msft's avatar
    v-haibl-msft
    Microsoft Employee

    MarcelBeug

     

    If we select a column with data type Date/Time/Timezone and do the transform, following error will be displayed which gives a clear explanation.

    Expression.Error: We cannot apply operator - to types DateTime and DateTimeZone.

     

    If you’d like the Power BI Team to change the generated code or disable Age calculation for Date/Time/Timezone data, please create an idea in https://ideas.powerbi.com.

     

    Best Regards,

    Herbert

  • MarcelBeug's avatar
    MarcelBeug
    Community Champion

    If I understand correctly, nothing was changed, so I would expect Status " Rejected".

    Otherwise I leave it to any Quality Control.