Forum Discussion

dannytan1112's avatar
dannytan1112
Helper I
3 years ago

Last Month

Hi,

 

I want to make a column that will return last month of the last year data as "last month"

DateNew Column 
2022/10/20October 
2022/10/21October 
2022/11/20November 
2022/11/21November 
2022/12/20December 
2022/12/21December 
2023/1/20Last Month 
2023/1/21Last Month 
   

 

My code is
New Column =

IF (
      MONTH([Date]) < MAX ('table[Date]'),
      FORMAT([Date],"MMMM"),

      IF(MONTH([Date]) = MONTH(MAX('table'[Date])),"Last Month", BLANK())

)

 

Thanks

1 Reply

  • dannytan1112 , you need column like

     

    Month Type = Switch( True(),
    eomonth([Date],0) = eomonth(Today(),-1*month(Today())),"Last year Last Month" ,
    eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
    eomonth([Date],0)= eomonth(Today(),0),"This Month" ,
    Format([Date],"MMM-YYYY")
    )