我对康德有疑问。与&(和)。
当我使用单个if条件时,例如:
Column =
IF (
'For PwerBi'[Cert type for TAT] = "Midterm Routine"
&& INT ( 24 * 'For PwerBi'[TAT excluding weekends_holidays] ) > 8,
">8Hrs",
"NA"
)我不会得到一个错误和输出来。
但是,当我添加一个IF条件时,比如:
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公式-
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])))))))))))))))))))发布于 2019-02-28 14:54:38
您的度量不能同时输出数字和文本。你必须选择一个或另一个。在第一个衡量标准中,这两个结果都是文本。在第二部分中,您的True结果是一个数字,而您的False结果是文本。
要解决这个问题,可以使用 function将数字转换为文本。
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"
)https://stackoverflow.com/questions/54926825
复制相似问题