Forum Discussion

TrentS's avatar
TrentS
Helper IV
6 years ago
Solved

Previous Month Value

Hi,   Tearing my hair out on this one due to inconsistency, so I need help. I have two data tables with similar structure. (No date table...yes, I know...). These tables are NOT related. Each tab...
  • jdbuchanan71's avatar
    6 years ago

    TrentS 

    The time intelligent functions rely on contiguous full year date ranges and you can see odd results if your dates don't cover full years.

    The first suggestion is to add a calendar table.  You can generate one in the model and it will look at the other date fields in the model to get the range.

    Dates = 
    VAR DateRange = CALENDARAUTO()
    RETURN
    ADDCOLUMNS(
        DateRange,
        "Year", YEAR ( [Date] ),
        "Month Name", FORMAT ( [Date], "mmmm"),
        "MonthNum", MONTH ( [Date] ),
        "Month Year", FORMAT ( [Date], "mmm-yyyy"),
        "YearMonthNum", YEAR ( [Date] ) * 100 + MONTH ( [Date] ),
        "QTR Year", "Q" & FORMAT ( [date],"Q-yyyy" ),
        "YearQtrNum", YEAR ( [Date] ) *100 + VALUE ( FORMAT ( [Date], "Q" ))
    )

    Or would you be able to share your .pbix file for us to review?  It's very hard to answer the question "What's wrong with my data?" when we can't see it.