Forum Discussion
adin
Helper I
4 years agocurrent and previous month in a single column
wandering why this calculated column only evaluates for the current month and not the previous month and year.
Period =
SWITCH(format(vwCalenderTable[TheDate],"yyyyMM"),
format(vwCalenderTable[today],"yyyyMM"),vwCalenderTable[ShortMonthYear],
format(DATEADD(STARTOFMONTH(vwCalenderTable[today]),-1,MONTH),"yyyyMM"),"Previous Month",
format(DATEADD(STARTOFMONTH(vwCalenderTable[today]),-12,MONTH),"yyyyMM"),"Same Period Previous Year",
Blank())
I want to use this column in a time series legend to show current, and previous periods against the day of the month.
Hi,
Use below code for your Column :
Period = Switch(format(Sheet159[theDate],"yyyyMM"),format(Sheet159[Today],"yyyyMM"),Sheet159[ShortMonthYear],Format(eomonth(Today(),-1), "yyyyMM"),"Previous Month",Format(eomonth(Today(),-12), "yyyyMM"),"Same period Previous",Blank())appreciate your Kudos
2 Replies
- amitchandak
Super User
adin , You can create a column like , Assume you have date column
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],"YYYY-MM")
) - MahyarTF
Memorable Member
Hi,
Use below code for your Column :
Period = Switch(format(Sheet159[theDate],"yyyyMM"),format(Sheet159[Today],"yyyyMM"),Sheet159[ShortMonthYear],Format(eomonth(Today(),-1), "yyyyMM"),"Previous Month",Format(eomonth(Today(),-12), "yyyyMM"),"Same period Previous",Blank())appreciate your Kudos