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 to only Use Last Month  but this is dynamic so as the month increases i would like the latest month to be filtered like Month -1

 

So it should say 

 

04 

 

05 then Last Month 

 

Thanks , James . 

  • 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!!

4 Replies

  • Hi JamesBurke - create a calculated column as below and se the month label as slicer in your chart. 

     

     

    Hope it helps

     

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

    • JamesBurke's avatar
      JamesBurke
      Helper III

      HI rajendraongole1 ,

      Thanks for this , This did help , I'm thinking to solve my problem i need a current Month and Prvious Month which i can filter to is not "Current Month"

      Month Label 2 = 
      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])
      RETURN
      'Date'[Mth & Yr] & 
      
      IF(DateMonth = LastMonth && DateYear = LastMonthYear,
      "Last Month")
      
      &
      
      IF(DateMonth = CurrentMonth && DateYear = LastMonthYear,
      "Current Month")
      



      Using Above but it returns 

       

       

      Just Not sure How to Format it correctly.

       

      Thanks James. 

      • rajendraongole1's avatar
        rajendraongole1
        Super User

        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!!