[英]PowerPivot DAX formula if then for dates
I have a column named ExpireDate
in my PowerPivot table (not PowerBI) and want to make another column based on the value of Today's Date
- ExpireDate
with a DAX formula like below: 我的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"))
But this formula keeps showing error messages, saying it needs a proper formula. 但是此公式始终显示错误消息,表示需要适当的公式。 Anybody knows how to deal with this problem?
有人知道如何处理这个问题吗? Thanks a lot.
非常感谢。
Assuming you are using Excel 2016, and your table name is "Table": 假设您使用的是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"
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.