Forum Discussion

wi11iamr's avatar
wi11iamr
Advocate II
9 years ago
Solved

Create DateKey, but with only one entry per month

Hi there,   Using the Calendar function I can happily create datekey tables which have anentry for each day of a month. I however need to create a datekey that only has the 1st day of each month, ...
  • v-ljerr-msft's avatar
    9 years ago

    Hi wi11iamr,

     

    In addition to Pfister's solution, you can also use STARTOFMONTH Function (DAX) to:

     

    Add a new calculate column to your existing Calendar table.

    First Day of Month = STARTOFMONTH('Date'[Date])

    Or you can create a new table with the new Datekey column from your existing Calendar table.

    Table = 
    DISTINCT (
        SELECTCOLUMNS ( 'Date', "NewDateKey", STARTOFMONTH ( 'Date'[Date] ) )
    )
    

     

    Regards