我的数据如下所示:
ContractID Start Date End Date
1 01.01.2020 23.03.2020
2 15.02.2020 29.07.2020
3 06.06.2020 null
最后一个合同仍然有效。我有一个日期表,其中开始日期为活动关系。
我也需要最终结果像这样:
Date Active Contracts
Jan 1
Feb 2
Mar 2
Apr 1
May 1
Jun 2
该度量的外观如何?
谢谢!
答案 0 :(得分:3)
假设您的日期表中有一个月
VAR currentMonth = SELECTEDVALUE(MyDataTable[Month value]) --needs to be a number 1 to 12
RETURN CALCULATE(COUNTROWS(MyDataTable),
ALL(DateTable),
MONTH(MyDataTable[Start Date]) >= currentMonth,
ISBLANK(MyDataTable[End Date]) || MONTH(MyDataTable[End Date]) <= currentMonth)