在 Tableau 中,我需要创建一个用作筛选器的字段,因为我需要在表中查看以下 YearMonth:本年本月、本年上月、上年当前月、上年上月
使用以下公式,我没有得到前一年的月份......有什么建议吗?
if datediff("year", [DATE_VALIDATION], today()) =0 /*and [DATE_VALIDATION]< TODAY()*/
and datediff("month", [DATE_VALIDATION], today()) =0 /*and [DATE_VALIDATION]< TODAY()*/
then "Current Year Current Month"
elseif datediff("year", [DATE_VALIDATION], today()) =0 /*and [DATE_VALIDATION]< TODAY()*/
and datediff("month",[DATE_VALIDATION], today())=1 and [DATE_VALIDATION] < DATEADD("month",-1,TODAY())
then "Current Year Previuous Month"
elseif datediff("year",[DATE_VALIDATION], today())=1 and [DATE_VALIDATION] < DATEADD("year",-1,TODAY())
and datediff("month", [DATE_VALIDATION], today()) =0
then "Previuos Year Current Month"
ELSEIF datediff("year",[DATE_VALIDATION], today())=1 and [DATE_VALIDATION] < DATEADD("year",-1,TODAY())
and datediff("month",[DATE_VALIDATION], today())=1 and [DATE_VALIDATION] < DATEADD("month",-1,TODAY())
then "Previuos Year Previous Month"