none
New to Power Query - Excel 2013 - Creating Custom Column with Syntax RRS feed

  • Question

  • I'm trying to insert a custom column.

    I want the column to grab the year out of another column labeled updated_time. The updated_time column is in the format of date/time. example) 3/17/2014 11:00:51 AM.

    I'm a newb as far as power query syntax goes.

    Can anyone point me in the right direction as far as what should be placed into the column formula portion?

    Thanks for any help.

    Thursday, March 20, 2014 6:54 PM

Answers

  • If the other column is already a date or datetime, then the formula you want is

    Date.Year([OtherColumnName])

    • Edited by Curt Hagenlocher Thursday, March 20, 2014 8:33 PM removed misleading period
    • Proposed as answer by Curt Hagenlocher Thursday, March 20, 2014 8:33 PM
    • Marked as answer by Ted_B Friday, March 21, 2014 7:08 PM
    Thursday, March 20, 2014 8:33 PM

All replies

  • If the other column is already a date or datetime, then the formula you want is

    Date.Year([OtherColumnName])

    • Edited by Curt Hagenlocher Thursday, March 20, 2014 8:33 PM removed misleading period
    • Proposed as answer by Curt Hagenlocher Thursday, March 20, 2014 8:33 PM
    • Marked as answer by Ted_B Friday, March 21, 2014 7:08 PM
    Thursday, March 20, 2014 8:33 PM
  • Curt's answer is great. You can do this through the UI too.

    1. Right click on the updated_time column and choose Duplicate Column
    2. Right click on the new column and choose Transform > Year

    (I reference right click for ease of writing but all the right click context menu commands are also available through the Query Editor ribbon.

    Thursday, March 20, 2014 9:16 PM
    Moderator