Forum Discussion

themistoklis's avatar
themistoklis
Icon for Community Champion rankCommunity Champion
8 years ago
Solved

Generate Customer Calendar using today's date as end date

Hello All,   I am using the following dax formula for the creation of the custom calendar     = Source(#date(2017, 01, 01), Duration.Days(#date(2018, 12, 31) - #date(2017, 01, 01))+1, #duration(...
  • danextian's avatar
    8 years ago

    Hi themistoklis,

     

    It seems that you are fairly new to Power BI.

     

    The formula you posted is not that of DAX but of M. If you want to create a calendar in DAX, you may use the CALENDAR() function. Example:

     

    CALENDAR TABLE =
    CALENDAR ( "1/1/2018", TODAY () )

    The above formula should be created as a table and not a measure or a calculated column.

     

    In M, you will have to create a list of dates first then convert it to a table. An example nested formula that generates a list of dates then converts the list to a table.

    = Table.FromList(
    List.Dates( #date(2018, 1, 1),  Number.From(DateTime.Date(DateTime.LocalNow())- #date(2018, 1, 1)) + 1, #duration(1, 0, 0, 0)), 
    Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error)

    From Get Data find Blank Query and then place the formula above into the formula bar. If the formula bar is not visible, go to View tab of Power Query Editor and then tick the checkbox for Formula Bar.