如果是日期,则使用PowerPivot DAX公式

时间:2018-09-24 02:22:44

标签: excel dax powerpivot

我在PowerPivot表(不是PowerBI)中有一个名为ExpireDate的列,并希望根据Today's Date-ExpireDate的值创建另一列,并使用DAX公式,如下所示:

=if(Format([ExpireDate] -today(), "General Number") <= 90, "Less than 3 months", 
 if(90 < Format( [ExpireDate] -today() ,"General Number") <= 180, " 3 to 6 months", 
 if([Format (ExpireDate]-today() ,"General Number") > 180, "More than 6 months","Other"))

但是此公式始终显示错误消息,表示它需要一个正确的公式。有人知道如何处理这个问题吗?非常感谢。

1 个答案:

答案 0 :(得分:1)

假设您使用的是Excel 2016,并且表名是“ Table”:

=
VAR Expiration = Table[ExpireDate] - TODAY ()
RETURN
    SWITCH (
        TRUE (),
        Expiration <= 90, "Less than 3 months",
        Expiration <= 180, " 3 to 6 months",
        Expiration > 180, "More than 6 months",
        "Other"
    )