Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Previous month value

Hi!

I think I'm going crazy... I made this simple value to calculate the value of last month but the output is BLANK.... What's wrong?

 

CalcRevenuePrevious = CALCULATE(SUM('table'[Revenue]); PREVIOUSMONTH('table'[YearMonthDate]))

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Can't tell you what is wrong without sample data to recreate. But, note the description of PREVIOUSMONTH from the documentation:

     

    Returns a table that contains a column of all dates from the previous month, based on the first date in the dates column, in the current context.

     

    From:

    https://msdn.microsoft.com/en-us/library/ee634758.aspx

     

    So, the first question would be are you sure that the first date in that table in the current context is really the month you want?

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      PREVIOUSMONTH('table'[YearMonthDate]) alone returns the value I want. My table is aggregated on user-month level with the first date of that month in this column. 

      Since this part of the formula works, I don't understand why the whole formula doesn't want to return a value. 

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        Going to need to see some sample data to recreate, but I would go with GilbertQ suggestion of a date table.