如何在同一PowerBi表中加入两个不同的日期?

时间:2019-04-17 19:33:48

标签: powerbi

我需要比较表的汇总结果,将两个不同的日期合并到同一表中,就像在POWERBI中这样:

最后得到一个像这样的表:

哪种方法是最好的?

1 个答案:

答案 0 :(得分:0)

我无法在单个Dax表表达式中使用此解决方案,请告知您是否可以做到:

//Create a calculated table 
Date_New = (DISTINCT(UNION(SUMMARIZE('Date', 'Date'[CreatedDate]), SUMMARIZE('Date', 'Date'[EndDate]))))

//Add 2 calculated columns to it
Created = 
VAR TotalCreated = CALCULATE(COUNT('Date'[CreatedDate]), FILTER('Date', 'Date'[CreatedDate] = 'Date_New'[CreatedDate]) )
RETURN IF(ISBLANK(TotalCreated), 0, TotalCreated) 

Ended = 
VAR TotalEnded = CALCULATE(COUNT('Date'[EndDate]), FILTER('Date', 'Date'[EndDate] = 'Date_New'[CreatedDate]) )
RETURN IF(ISBLANK(TotalEnded), 0, TotalEnded) 

结果:

enter image description here