AWS Quicksight使用ifelse函数合并日期列结果异常及报错问题
日期列合并IFELSE公式错误修复方案
错误原因分析
- 第一个公式
ifelse(RewardPaidDate = null,rewarddate, RewardPaidDate)失效原因:null是数据库/BI工具中的特殊未知值,无法用=运算符直接判断相等,RewardPaidDate = null的返回结果恒为未知,因此逻辑永远走不到取rewarddate的分支,只会原样返回RewardPaidDate,空值自然会保留。 - 第二个公式
ifelse(RewardPaidDate = '',rewarddate, RewardPaidDate)报错原因:RewardPaidDate是日期类型字段,''属于字符串类型,两种不同数据类型的值直接比较触发了类型不匹配错误。
正确写法
使用专门的空值判断函数校验RewardPaidDate是否为空即可,通用写法如下:
ifelse(isNull(RewardPaidDate), rewarddate, RewardPaidDate)
如果你的工具中isNull不生效,可尝试替换为isnull、IS NULL语法,SQL原生写法参考:
IF(RewardPaidDate IS NULL, rewarddate, RewardPaidDate) AS RewardSentDate
内容的提问来源于stack exchange,提问作者tidy2021
相关产品推荐
相关产品推荐

