如何使用M语言从现有表创建聚合表

时间:2018-07-13 23:09:57

标签: powerbi m powerbi-desktop

我有一张表格-Power BI中的MemberJoin,如下所示:

enter image description here

我想使用M语言从MemberJoin创建一个聚合表。可以吗如果是,该如何在M中完成?

下面是相应的SQL语句,然后是新表的屏幕快照。

select [YTD Flag], [Member Type], year([Join Date]) "Year",
       MONTH([Join Date]) "Month", datename(MONTH, [Join Date]) "MonthName",
       [Join Channel],  COUNT(*) "Count", 
       cast(count([YTD Flag]) as float) / cast(sum(count([YTD Flag])) 
        over (partition by year([Join Date])) as float) "Prcnt by Year"
from [MemberJoin]
group by [YTD Flag], [Member Type], [Join Channel], year([Join Date]), MONTH([Join Date]), datename(MONTH, [Join Date]) 
order by [YTD Flag] desc, [Member Type] desc, Year desc, Month, [Join Channel];

enter image description here

1 个答案:

答案 0 :(得分:1)

“分组依据”命令位于“查询”编辑器的“主页”功能区上。您可以使用“高级”选项创建一个简单的分组,或更复杂的分组,然后添加更多分组和/或聚合。

enter image description here