Powerbi-矩阵日期表&矩阵列数据表头排序

 首先做一个DAX日期表,Powerbi中新建表输入如下代码即可

Powerbi-矩阵日期表&矩阵列数据表头排序_第1张图片 

Powerbi-矩阵日期表&矩阵列数据表头排序_第2张图片 

日期表 = 

VAR YearStart = 2023    //起始年度
VAR YearEnd = 2024      //结束年度

VAR WeekNumberType = 2
VAR WeekDayType = 2

RETURN
GENERATE (
    CALENDAR( DATE( YearStart , 1 , 1 ) , DATE( YearEnd , 12 , 31 ) ),
    // CALENDAR( DATE( YearStart , 1 , 1 ) , TODAY() ),
    VAR Year = YEAR ( [Date] )
    VAR Month = MONTH ( [Date] )
    VAR Quarter = QUARTER( [Date] )
    VAR Day = DAY( [Date] )
    VAR Weekday = WEEKDAY( [Date] , WeekDayType )
    VAR Week_num = WEEKNUM([Date],WeekNumberType)
    VAR Week_start = FORMAT([Date]-Weekday+1,"YYYY-MM-DD")
    VAR Week_end = FORMAT([Date]-Weekday+7,"YYYY-MM-DD")
    RETURN ROW (
        "年" , Year ,
        "季" , Quarter ,
        "月" , Month ,
        "日" , Day ,
        "周",Weekday,
        "周数",Week_num,
        "星期",RIGHT(FORMAT([Date],"AAA"),1)
    )
)

随后创建一个矩阵,行、列、值字段 如下图所示

最后因为行表头是错序的,所以需要调整一下 如下图点击星期,点击上方按列排序 

Powerbi-矩阵日期表&矩阵列数据表头排序_第3张图片

你可能感兴趣的:(powerbi,矩阵,excel)