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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

0

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}})

Status: Delivered
Comments
MarcelBeug
Community Champion

Likewise for Add Column - Date - Age,

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

Vicky_Song
Impactful Individual
Status changed to: Delivered
 
MarcelBeug
Community Champion

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

Otherwise I leave it to any Quality Control.