我想计算运行总计而不填充空白或将来的日期

时间:2019-06-19 07:17:20

标签: powerbi dax

我创建了一个dax函数来计算运行总计。数据着眼于数月实际值与目标值。目标已经被填充,但是没有实际的未来目标需要我们同时显示两者。我需要修改dax函数以将空白月份作为空白。

代码:

Cum_Actual =
CALCULATE (
    SUM ( Calv_ME_Telkom_Mobile_performance[Actual] ),
    FILTER (
        ALLEXCEPT (
            Calv_ME_Telkom_Mobile_performance,
            Calv_ME_Telkom_Mobile_performance[Region],
            Calv_ME_Telkom_Mobile_performance[Order_type]
        ),
        Calv_ME_Telkom_Mobile_performance[Month]
            <= MAX ( Calv_ME_Telkom_Mobile_performance[Month] )
    )
)

预期结果:

Date      |Actual|Target  |Running Total
01/04/2019|    85|     100|           85
01/05/2019|    52|      70|          137
01/06/2019|    69|      80|          206
01/07/2019|      |      70|

1 个答案:

答案 0 :(得分:0)

解决方案:

Cum_Actual =
CALCULATE (
    IF(SUM ( Calv_ME_Telkom_Mobile_performance[Actual] ) < 1, "", 
SUM ( Calv_ME_Telkom_Mobile_performance[Actual] )),
    FILTER (
        ALLEXCEPT (
            Calv_ME_Telkom_Mobile_performance,
            Calv_ME_Telkom_Mobile_performance[Region],
            Calv_ME_Telkom_Mobile_performance[Order_type]
        ),
        Calv_ME_Telkom_Mobile_performance[Month]
            <= MAX ( Calv_ME_Telkom_Mobile_performance[Month] )
    )
)