具有多个时间智能过滤器的DistinctCount

问题描述 投票:0回答:1

有没有办法将我的语法简化为单个计算 DistinctCount?

我的询问

CALCULATE( (
    CALCULATE(
            DISTINCTCOUNT('Sales Invoice'[Customer Code]),
            DATESBETWEEN(DimDate[Date], EDATE(MIN(DimDate[Date]), -5), EDATE(MAX(DimDate[Date]), 0))
    ) = 0 
    &&
    CALCULATE(
            DISTINCTCOUNT('Sales Invoice'[Customer Code]),
            DATESBETWEEN(DimDate[Date], EDATE(MIN(DimDate[Date]), -6), EDATE(MAX(DimDate[Date]), -6))
    ) = 1
)

我想检查多个时间智能过滤器,例如客户在 3 个月前有最后记录,而 2 个月前没有记录。

有这样的查询吗?

CALCULATE(
            DISTINCTCOUNT('Sales Invoice'[Customer Code]),
            DATESBETWEEN(DimDate[Date], EDATE(MIN(DimDate[Date]), -2), EDATE(MAX(DimDate[Date]), -1)) = 0 &&
            DATESBETWEEN(DimDate[Date], EDATE(MIN(DimDate[Date]), 0), EDATE(MAX(DimDate[Date]), 0)) = 1
    )
powerbi dax ssas ssas-tabular
1个回答
0
投票

尝试这个措施:

Measure = 
VAR thisDate = TODAY()
RETURN
CALCULATE(
            DISTINCTCOUNT('Sales Invoice'[Customer Code]),
            (DimDate[Date] > EDATE(thisDate, -3) && EDATE(thisDate, -1) > DimDate[Date] ) // Include 3 months ago from today's date
            && NOT (DimDate[Date] > EDATE(thisDate, -2) && EDATE(thisDate, -1) > DimDate[Date] ) // Exclude 2 months ago from today's date
)
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.