Forum Discussion

JamesBurke's avatar
JamesBurke
Helper III
2 years ago
Solved

Last Month

Hi All ,    Month 2 = IF( 'Date'[Mth & Yr] = DATE(YEAR(TODAY()),MONTH(TODAY())-1,1), "Last Month", FORMAT('Date'[Mth & Yr] , "MM-DD-YYYY") )     I have the above Measure , i'm trying t...
  • rajendraongole1's avatar
    rajendraongole1
    2 years ago

    Hi JamesBurke - if you want to show last month and current month with right format, create a calculate column as below 

    MonthLabel2 =
    VAR CurrentMonth = MONTH(TODAY())
    VAR CurrentYear = YEAR(TODAY())
    VAR LastMonth = IF(CurrentMonth = 1, 12, CurrentMonth - 1)
    VAR LastMonthYear = IF(CurrentMonth = 1, CurrentYear - 1, CurrentYear)
    VAR DateMonth = MONTH('Date'[Date])
    VAR DateYear = YEAR('Date'[Date])
    VAR Label =
        IF(DateMonth = LastMonth && DateYear = LastMonthYear, "Last Month",
        IF(DateMonth = CurrentMonth && DateYear = CurrentYear, "Current Month",
        FORMAT('Date'[Date], "MM-DD-YYYY")))

    RETURN Label

     

     

    Hope it resolve the issue. 

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!!