首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有&& (多条件)变量数据类型错误的IF

具有&& (多条件)变量数据类型错误的IF
EN

Stack Overflow用户
提问于 2019-02-28 13:25:01
回答 1查看 967关注 0票数 2

我对康德有疑问。与&(和)。

当我使用单个if条件时,例如:

代码语言:javascript
复制
Column =
IF (
    'For PwerBi'[Cert type for TAT] = "Midterm Routine"
        && INT ( 24 * 'For PwerBi'[TAT excluding weekends_holidays] ) > 8,
    ">8Hrs",
    "NA"
)

我不会得到一个错误和输出来。

但是,当我添加一个IF条件时,比如:

代码语言:javascript
复制
Column =
IF (
    'For PwerBi'[Cert type for TAT] = "Midterm Routine"
        && INT ( 24 * 'For PwerBi'[TAT excluding weekends_holidays] ) < 8,
    INT ( 24 * [TAT excluding weekends_holidays] ),
    "NA"
)

它给了我一个错误:

“生成可变数据类型的表达式不能用于定义计算的列。”

我不明白这个错误的意思。为什么会出现?

这是我最初的dax公式-

代码语言:javascript
复制
Column 2 = IF('For PwerBi'[Cert type for TAT]="MR" && INT(24*'For PwerBi'[TAT excluding weekends_holidays])>8,">8Hrs",

IF('For PwerBi'[Cert type for TAT]="MR" && INT(24*'For PwerBi'[TAT excluding weekends_holidays])<=8,FORMAT( INT ( 24 * [TAT excluding weekends_holidays] ), "0" ), 

IF('For PwerBi'[Cert type for TAT]="MRR" && 'For PwerBi'[TAT excluding weekends_holidays]<TIMEVALUE("00:30:00"),"<30Min",

IF('For PwerBi'[Cert type for TAT]="MRR" && 'For PwerBi'[TAT excluding weekends_holidays]>=TIMEVALUE("00:30:00") && 'For PwerBi'[TAT excluding weekends_holidays]<TIMEVALUE("01:00:00"),"30 Min - 1 Hr",

IF('For PwerBi'[Cert type for TAT]="MRR" && 'For PwerBi'[TAT excluding weekends_holidays]>=TIMEVALUE("01:00:00") && 'For PwerBi'[TAT excluding weekends_holidays]<TIMEVALUE("01:30:00"),"1 Hr - 1.5 Hr",

IF('For PwerBi'[Cert type for TAT]="MRR" && 'For PwerBi'[TAT excluding weekends_holidays]>=TIMEVALUE("01:30:00") && 'For PwerBi'[TAT excluding weekends_holidays]<TIMEVALUE("02:00:00"),"1.5 Hr - 2 Hr",

IF('For PwerBi'[Cert type for TAT]="MRR" && 'For PwerBi'[TAT excluding weekends_holidays]>=TIMEVALUE("02:00:00") && 'For PwerBi'[TAT excluding weekends_holidays]<TIMEVALUE("02:30:00"),"2 Hr - 2.5 Hr",

IF('For PwerBi'[Cert type for TAT]="MRR" && 'For PwerBi'[TAT excluding weekends_holidays]>=TIMEVALUE("02:30:00") && 'For PwerBi'[TAT excluding weekends_holidays]<TIMEVALUE("03:00:00"),"2.5 Hr - 3 Hr",

IF('For PwerBi'[Cert type for TAT]="MRR" && 'For PwerBi'[TAT excluding weekends_holidays]>=TIMEVALUE("03:00:00") && 'For PwerBi'[TAT excluding weekends_holidays]<TIMEVALUE("03:30:00"),"3 Hr - 3.5 Hr",

IF('For PwerBi'[Cert type for TAT]="MRR" && 'For PwerBi'[TAT excluding weekends_holidays]>=TIMEVALUE("03:30:00") && 'For PwerBi'[TAT excluding weekends_holidays]<TIMEVALUE("04:00:00"),"3.5 Hr - 4 Hr",

IF('For PwerBi'[Cert type for TAT]="MRR" && 'For PwerBi'[TAT excluding weekends_holidays]>=TIMEVALUE("04:00:00"),"> 4 Hr",

IF('For PwerBi'[Cert type for TAT]="Rnw" && INT(24*'For PwerBi'[TAT excluding weekends_holidays])<8,"< 8 Hrs",

IF('For PwerBi'[Cert type for TAT]="Rnw" && INT(24*'For PwerBi'[TAT excluding weekends_holidays])>=8 && INT(24*'For PwerBi'[TAT excluding weekends_holidays])<16,"8 - 16 hrs",

IF('For PwerBi'[Cert type for TAT]="Rnw" && INT(24*'For PwerBi'[TAT excluding weekends_holidays])>=16 && INT(24*'For PwerBi'[TAT excluding weekends_holidays])<24,"16 - 24 hrs",

IF('For PwerBi'[Cert type for TAT]="Rnw" && INT(24*'For PwerBi'[TAT excluding weekends_holidays])>=24 && INT(24*'For PwerBi'[TAT excluding weekends_holidays])<36,"24 hrs - 36 hrs",

IF('For PwerBi'[Cert type for TAT]="Rnw" && INT(24*'For PwerBi'[TAT excluding weekends_holidays])>=36 && INT(24*'For PwerBi'[TAT excluding weekends_holidays]),"36 hrs - 48 hrs",

IF('For PwerBi'[Cert type for TAT]="Rnw" && INT(24*'For PwerBi'[TAT excluding weekends_holidays])>=48,"> 48 hrs",

IF('For PwerBi'[Cert type for TAT]="NA","NA",INT(24*'For PwerBi'[TAT excluding weekends_holidays])))))))))))))))))))
EN

回答 1

Stack Overflow用户

发布于 2019-02-28 14:54:38

您的度量不能同时输出数字和文本。你必须选择一个或另一个。在第一个衡量标准中,这两个结果都是文本。在第二部分中,您的True结果是一个数字,而您的False结果是文本。

要解决这个问题,可以使用 function将数字转换为文本。

代码语言:javascript
复制
Column =
IF (
    'For PwerBi'[Cert type for TAT] = "Midterm Routine"
        && INT ( 24 * 'For PwerBi'[TAT excluding weekends_holidays] ) < 8,
    FORMAT( INT ( 24 * [TAT excluding weekends_holidays] ), "0" ),
    "NA"
)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54926825

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档