Add a DateKey Column in PowerBI M Lang

Date's can get difficult to merge on other date or datetime fields. Use this function to convert to a DateKey or Date ID

me@jaykilleen.com wrote this over 4 years ago and it was last updated over 4 years ago.


← Back to the Posts


  AddDateKey = Table.AddColumn(LastQueryStep, "DateKey", 
    each 
      Number.ToText(Date.Year([CreatedDate])) &
      Text.PadStart(Number.ToText(Date.Month([CreatedDate])),2,"0") &
      Text.PadStart(Number.ToText(Date.Day([CreatedDate])),2,"0"
    )
  )

Similar