我在db.collection.aggregate([{ $match: { field1: 'A' } }, {
$project: {
field1: 1, array1: {
$size: {
$filter: {
"input": "$array1",
"as": 'each',
"cond": { "$eq": ["$$each.field_1", "true"] }
}
}
}
}
}])
函数中有一个表表达式。
如何在我的方案中获得总计“打开”列?
SUMX()
更新:感谢@ CR7SMS。
但是现在看起来有点高了:
我尝试过:
TestMeasure =
SUMX (
ADDCOLUMNS (
SUMMARIZE (
FILTER (
SumByClaim,
SumByClaim[TransactionDate] >= FIRSTDATE ( SumByClaim[TransactionDate] )
&& SumByClaim[TransactionDate] <= LASTDATE ( SumByClaim[TransactionDate] )
),
SumByClaim[ClaimNumber],
SumByClaim[ClaimantID],
SumByClaim[ClaimStatus],
"MaxTransDate", MAX ( SumByClaim[TransactionDate] )
),
"Open", IF (
SumByClaim[ClaimStatus] = "Open"
&& [MaxTransDate] = MAX ( SumByClaim[TransactionDate] ),
1,
0
)
),
[Open]
)
答案 0 :(得分:0)
我在计算中添加了SUMX,这给了我更高的总数。我不确定结果是否是您想要的,但是您可以尝试一下:
TestMeasure =
SUMX(SumByClaim,SUMX (
ADDCOLUMNS (
SUMMARIZE (
FILTER (
SumByClaim,
SumByClaim[TransactionDate] >= FIRSTDATE ( SumByClaim[TransactionDate] )
&& SumByClaim[TransactionDate] <= LASTDATE ( SumByClaim[TransactionDate] )
),
SumByClaim[ClaimNumber],
SumByClaim[ClaimantID],
SumByClaim[ClaimStatus],
"MaxTransDate", MAX ( SumByClaim[TransactionDate] )
),
"Open", IF (
SumByClaim[ClaimStatus] = "Open"
&& [MaxTransDate] = MAX ( SumByClaim[TransactionDate] ),
1,
0
)
),
[Open]
))