我要让DAX做的是:
这本质上是用普通的英语提问:“对于我的每位员工,有多少个具有相同职称的员工在该员工上任后一个月内成功完成了他们的任务?”在DAX中基本上只是“如何将多个过滤条件应用于SUMX或COUNTAX度量/计算列?”
我已经尝试过的措施是:
Contractors Available = COUNTAX(
'BAT VwRptMspAssignment',
CALCULATE(
DISTINCTCOUNT('BAT VwRptMspAssignment'[assignmentgk]),
FILTER(
FILTER(
FILTER(
FILTER(
FILTER(ALL('BAT VwRptMspAssignment'),
'BAT VwRptMspAssignment'[End.Date]<EARLIER('BAT VwRptMspAssignment'[Start.Date])+31),
'BAT VwRptMspAssignment'[End.Date]>EARLIER('BAT VwRptMspAssignment'[Start.Date])-31),
'BAT VwRptMspAssignment'[Start.Date]<EARLIER('BAT VwRptMspAssignment'[Start.Date])),
'BAT VwRptMspAssignment'[EoaReason]="Successful Completion"),
'BAT VwRptMspAssignment'[JobPostingTitle.1]=EARLIER('BAT VwRptMspAssignment'[JobPostingTitle.1]))
)
)
我尝试的计算列是:
Contractors Available.1 = SUMX(
FILTER(
FILTER(
FILTER(
FILTER(
FILTER(
FILTER(ALL('BAT VwRptMspAssignment'),
'BAT VwRptMspAssignment'[customergk]=EARLIER('BAT VwRptMspAssignment'[customergk])),
'BAT VwRptMspAssignment'[JobPostingTitle.1]=EARLIER('BAT VwRptMspAssignment'[JobPostingTitle.1])),
'BAT VwRptMspAssignment'[End.Date]<EARLIER('BAT VwRptMspAssignment'[Start.Date])+31),
'BAT VwRptMspAssignment'[End.Date]>EARLIER('BAT VwRptMspAssignment'[Start.Date])-31),
'BAT VwRptMspAssignment'[Start.Date]<EARLIER('BAT VwRptMspAssignment'[Start.Date])),
'BAT VwRptMspAssignment'[EoaReason]="Successful Completion"),
'BAT VwRptMspAssignment'[FinishFlag])
但这些解决方案均无效。
有谁知道为什么或还有什么我可以尝试实现这一目标?导出到Excel的数据格式示例:
“可用的承包商2”是计算所得的列。
请注意第一行中的521。如果我在Excel中应用所有这些过滤器,则应为零,此职位在数据集中是唯一的。它说107个“技术作家-专家”行应该在2017年9月26日的一个月内结束,但是这些是数据集中仅有的3位技术作家,其他两个中的零个在9 / 30/2016:
答案 0 :(得分:1)
尝试对计算所得的列执行以下操作:
Contractors Available.1 =
VAR StartDate = 'BAT VwRptMspAssignment'[Start.Date]
VAR JobTitle = 'BAT VwRptMspAssignment'[JobPostingTitle.1]
RETURN
COUNTROWS (
FILTER (
'BAT VwRptMspAssignment',
'BAT VwRptMspAssignment'[End.Date] < StartDate + 31
&& 'BAT VwRptMspAssignment'[End.Date] > StartDate - 31
&& 'BAT VwRptMspAssignment'[Start.Date] < StartDate
&& 'BAT VwRptMspAssignment'[EoaReason] = "Successful Completion"
&& 'BAT VwRptMspAssignment'[JobPostingTitle.1] = JobTitle
)
)
不需要EARLIER函数,因为变量将保留上下文的定义位置,即rowcontext。
编辑: 我使用您提供的数据测试了我的公式,它似乎起作用了。我在第二行中更改了[End.Date],以便在第一行中获得结果。