一、基础知识
1,环比:MOM (Month over Month ) = (当前月金额- 上月金额)/上月金额*100
2,同比:YOY (Year over Year ) = (当前月金额- 上一年金额)/上一年金额*100
3,年累计:YTD(Year to day) 年初到今日的销售额之和。
4,季累计:QTD(Quarter to day) 季初到今日的销售额之和。
5,月累计:MTD(Month to day) 月初到今日的销售额之和。
6,移动年度总计:MAT 过去12月销售之和。
二、如何创建时间表
date = var TEMP1 = calendar (date (2022,1,1), date (2025,12,30))
return
ADDCOLUMNS( TEMP1,
"max_date" , date(2999,12,30),--自定义一个最大日期"month_num", DATEDIFF( [date]-1, eomonth([date],0),day), //月底减去每天得到日期"min_date" , datevalue("1900/01/01"),
"day", day([date]),//返回一月中日期1-31数字
"edate", edate([date],1),// 返回一个月之后的日期
"eomonth0" ,eomonth([date],1),--平移指定月份然后取月底日期
"Hour", hour([date]),-- 取小时
"now_date",now(),-- 返回一个日期和时间
"TIME" ,time(9,30,48),-- 返回一个时间
"today",TODAY(),--返回0点时间
"utctoday",utcTODAY(),--返回0点时间
//"endofmonth" ,ENDOFMONTH('DATE'[Date].[Date]) ,
// "endofquarter" ,ENDOFQUARTER('DATE'[Date].[Date]) ,
// "endofyear" ,ENDOFyear('DATE'[Date].[Date]) ,
// "dateadd1" ,dateadd('calendar'.[date].[date],1,day),-- 粒度day,month,quarter,year
"year_code" ,year([date]),
"year_desc" ,year([date])&"年",
"half_code" , if(month([date])<=6,"H1","H2"),
"half_code_desc" , if(month([date])<=6,"上半年","下半年"),
"quarter",roundup(month([date])/3,0),
"quarter_desc",roundup(month([date])/3,0)&"Q",
"year_quarter",year([date])& roundup(month([date])/3,0),
"year_quarter_desc",year([date])&"-"& roundup(month([date])/3,0)&"Q",
"month",month([date]),
"month_code",format([Date],"MM"),
"month_code1",month([date])&"月",
"year_month",year([date])& month([date]),
"year_month_code",year([date])& format( [date] ,"mm"),
"year_month_desc",year([date])&"年"& format( [date] ,"mm")&"月",
"weekday",weekday([date],1),--n=1 默认 周日是1,
"weekday1",weekday([date],2),
"weekday_desc",switch(weekday([date],1),1,"星期日",2,"星期一",3,"星期二",4,"星期三",5,"星期四",6,"星期五",7,"星期六"),--n=1 默认 周日是1,
"week1",weeknum([date],1),--周日开始
"week2",weeknum([date],2),--周一开始
"week11",weeknum([date],11),--周一开始
"week12",weeknum([date],12),--周一开始
"week13",weeknum([date],13),--周一开始
"week14",weeknum([date],14),--周一开始
"week15",weeknum([date],15),--周一开始
"week16",weeknum([date],16),--周一开始
"week17",weeknum([date],17),--周一开始"week21",weeknum([date],21)--ISO跨年周
)
三、各种应用场景