Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Extract month and year from date

Hi,    I'm trying to do a report that tracks completed actions in months over the past 2 years. Therefore I need to extract the month and year from a date into a new column. I have tried the month ...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous 

    Did you use format function to build extract month and year?

    If you use format "YYYY" and format "MM", "YYYYMM",your result will show text type.

    Power Query:

    Select Date column and click Date in Add column.

    Then add a custom column and change it type to whole number.

    Dax:

    In addition to  

    Dax_YearMonth = YEAR('Table'[Date])*100+MONTH('Table'[Date])

    Result is as below.

    Best Regards,

    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.