Forum Discussion

Walt1010's avatar
Walt1010
Helper V
1 year ago
Solved

Getting Going with Time Intelligence

I have a file of leave data that has sickness leave data for approximately 2.4 years. I have defined various measures such as total staff, sickness rate and days lost, I need to show the summary metr...
  • Greg_Deckler's avatar
    1 year ago

    Walt1010 You need to mark your table as a date table for the DAX TI functions to work "reliably". However, I would highly recommend using offsets instead in your date table. Also, have a look at the following. You may find this helpful - https://medium.com/@gdeckler/to-bleep-with-time-intelligence-0b0c2a4708d9 

    Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

    https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TITHW/m-p/434008

  • wardy912's avatar
    1 year ago

    Hi Walt1010 

     

    If you want to improve your date table for future projects, here's the calendar I always use. Replace the MIN/MAX with dates from your primary data table for dynamic start and end dates

    Date = 
    ADDCOLUMNS (
        CALENDAR (
            MIN ( [Date column from existing table] ),
            MAX ( [Date column from existing table] )
        ),
        "MonthNo", MONTH ( [Date] ),
        "MonthName", FORMAT ( [Date], "MMMM" ),
        "MonthYear", FORMAT ( [Date], "MMMM YYYY" ),
        "MonthYearShort", FORMAT ( [Date], "MMM YY" ),
        "MonthYearNo", FORMAT ( [Date], "YYYYMM" ),
        "Quarter", QUARTER ( [Date] ),
        "Year", YEAR ( [Date] ),
        "Day", DAY ( [Date] ),
        "WeekNumber", WEEKNUM ( [Date] ),
        "WeekdayNum", WEEKDAY ( [Date] ),
        "WeekdayName", FORMAT ( [Date], "DDDD" ),
        "PreviousWeek", WEEKNUM ( [Date] ) -1 ,
        "WeekStartDate", ([Date] - WEEKDAY ( [Date] , 1 ) +1),
        "WeekEndDate", ([Date] - WEEKDAY ( [Date] , 1 ) +7),
        "YearMonth", FORMAT ( [Date], "YYYY-M" ),
        "Financial Year", IF (MONTH ([Date]) >= 1 && MONTH ([Date]) <= 12, YEAR ([Date]), YEAR ([Date]) + 1)
    )

     

    Once marked as the date table, you can add a variety of measures, some examples below

     

    -- Total Days Lost This Year (Calendar)
    DaysLost_CY := CALCULATE([Days Lost], DATESYTD('Date'[Date]))
    
    -- Total Days Lost This Financial Year
    DaysLost_FY := CALCULATE([Days Lost], DATESYTD('Date'[Date], "06/30"))
    
    -- Sickness Rate Last Year
    SicknessRate_LY := CALCULATE([Sickness Rate], SAMEPERIODLASTYEAR('Date'[Date]))

     

    Hope this helps, please give a thumbs up and mark as solved if it does, thanks!