Forum Discussion

Caldowd98's avatar
Caldowd98
Helper I
3 years ago
Solved

Date Table

Hi community

 

I have a dataset where the last entry against a date is 01.09.2022. My current date table (below) returns a date table with the last date 31.12.2022.

How would i change this so it returns the maximum date in the dataset and not the final day of the year of this date ?

 

Date Table =
ADDCOLUMNS(
CALENDARAUTO(),
"YEAR", YEAR([Date]),
"Month", FORMAT([Date], "mmmm"),
"MONTH NUMBER", MONTH([Date]))
 
Thanks!! 🙂
  • Let's say the date field in your fact table is called 'FactTable'[Date]

    You can limit the start and end date in the calendar table by using:

    Date Table =
    VAR _MinDate =
        MIN ( FactTable[Date] )
    VAR _MaxDate =
        MAX ( FactTable[Date] )
    RETURN
        ADDCOLUMNS (
            CALENDAR ( _MinDate, _MaxDate ),
            "YEAR", YEAR ( [Date] ),
            "Month", FORMAT ( [Date], "mmmm" ),
            "MONTH NUMBER", MONTH ( [Date] )
        )
    

     

3 Replies

  • PaulDBrown's avatar
    PaulDBrown
    Community Champion

    Let's say the date field in your fact table is called 'FactTable'[Date]

    You can limit the start and end date in the calendar table by using:

    Date Table =
    VAR _MinDate =
        MIN ( FactTable[Date] )
    VAR _MaxDate =
        MAX ( FactTable[Date] )
    RETURN
        ADDCOLUMNS (
            CALENDAR ( _MinDate, _MaxDate ),
            "YEAR", YEAR ( [Date] ),
            "Month", FORMAT ( [Date], "mmmm" ),
            "MONTH NUMBER", MONTH ( [Date] )
        )