Creating a Date Table in Power BI | Scribe

    Creating a Date Table in Power BI

    • Microsoft Power BIMicrosoft Power BI

    Creating the Table

    Click [[New table]]
    +00:00:02.4
    In the formula bar, remove "Table =" and enter in the below code.
    +00:00:06.3
    [[Date =]] [[ADDCOLUMNS (]] [[    CALENDAR (DATE(2015, 1, 1), DATE(2050, 12, 31)),]] [[    "Year", YEAR(\[Date\]),]] [[    "Month Number", MONTH(\[Date\]),]] [[    "Month Name", FORMAT(\[Date\], "MMMM"),]] [[    "Day", DAY(\[Date\]),]] [[    "Quarter",]] [[    SWITCH(]] [[        TRUE(),]] [[        MONTH(\[Date\]) IN {1, 2, 3}, "Q3",]] [[        MONTH(\[Date\]) IN {4, 5, 6}, "Q4",]] [[        MONTH(\[Date\]) IN {7, 8, 9}, "Q1",]] [[        MONTH(\[Date\]) IN {10, 11, 12}, "Q2"]] [[    ),]] [[    "Year-Quarter",]] [[    YEAR(\[Date\]) & "-Q" &]] [[    SWITCH(]] [[        TRUE(),]] [[        MONTH(\[Date\]) IN {1, 2, 3}, "3",]] [[        MONTH(\[Date\]) IN {4, 5, 6}, "4",]] [[        MONTH(\[Date\]) IN {7, 8, 9}, "1",]] [[        "2"]] [[    )]] [[)]]
    +00:00:08.3
    Remember to set your date range and financial quarters to suit your requirements. This example is going to create a date range from 1st Jan 2015 to 31st Dec 2050, with Q1 starting 1st July.

    Changing the Date Format

    This is an optional step, but for my preference I like to change to the DD/MM/YYYY format.
    Select the [[Date]] column
    +00:00:19.4
    under [[Column Tools]] select the format that matches your requirement.

    Marking as Date Table

    Along the Data navigation pane on the right, right click on the table.
    +00:00:23.6
    Click "Mark as date table"
    +00:00:25.6
    Thurn this on.
    +00:00:27.9
    Click "Choose a column", and select the primary date column.
    Once done, you'll see the validation would have succeeded.
    +00:00:32.8
    Click [[Save]] to exit.
    +00:00:33.3
    Was this Scribe helpful?
    Save this document for future reference.
    click-target-circles-background
    0 Selected
    This Scribe is in tip-top shape!Leave feedback if there are any issues with this Scribe