嗨,我试图根据两个度量值来获得最后一列,我使用的是Power BI,但是我对此并不陌生。这是公式。我遇到错误“功能开关不支持将true / false类型的值与text类型的值进行比较”
SWITCH(
AND(('Table'[ar]*100)>=-100,('Table'[ar]*100)<=-5),
SWITCH(
AND(('Table'[br]*100)>=-5,('Table'[br]*100)<=5),"DROP TO AVG",
AND(('Table'[br]*100)<=100,('Table'[br]*100)>=5),"DROP TO HIGH",
AND(('Table'[br]*100)>=-100,('Table'[br]*100)<=-5),"BAD ALERT"),
AND(('Table'[ar]*100)>=-5,('Table'[ar]*100)<=5),
SWITCH(
AND(('Table'[br]*100)<=100,('Table'[br]*100)>=5),"KEEP HIGH",
AND(('Table'[br]*100)>=-100 ,('Table'[br]*100)<=-5),"KEEP LOW"),
AND(('Table'[ar]*100)<=100,('Table'[ar]*100)>=5),
SWITCH(
AND(('Table'[br]*100)>=-5,('Table'[br]*100)<=5),"INCREASE TO AVG",
AND(('Table'[br]*100)>=-100,('Table'[br]*100)<=-5),"INCREASE TO LOW",
AND(('Table'[br]*100)<=100,('Table'[br]*100)>=5),"GOOD ALERT"))
答案 0 :(得分:1)
由于在AND
函数中包含一些错误的括号,因此出现了该错误。例如。 AND(('Table'[br]*100)>=-100,('Table'[br]*100)<=-5),"BAD ALERT"),
。文本在逻辑上不能与True / False组合。
我认为您正在寻找更像这样的东西:
SWITCH(TRUE(),
('Table'[ar]*100 >= -100) && ('Table'[ar]*100 <= -5),
SWITCH(TRUE(),
('Table'[br]*100 >= -5 ) && ('Table'[br]*100 <= 5), "DROP TO AVG",
('Table'[br]*100 <= 100) && ('Table'[br]*100 >= 5), "DROP TO HIGH",
('Table'[br]*100 >= -100) && ('Table'[br]*100 <= -5), "BAD ALERT"
),
('Table'[ar]*100 >= -5) && ('Table'[ar]*100 <=5),
SWITCH(TRUE(),
('Table'[br]*100 <= 100) && ('Table'[br]*100 >= 5), "KEEP HIGH",
('Table'[br]*100 >= -100) && ('Table'[br]*100 <= -5), "KEEP LOW"
),
('Table'[ar]*100 <= 100) && ('Table'[ar]*100 >= 5),
SWITCH(TRUE(),
('Table'[br]*100 >= -5 ) && ('Table'[br]*100 <= 5), "INCREASE TO AVG",
('Table'[br]*100 >= -100) && ('Table'[br]*100 <= -5), "INCREASE TO LOW",
('Table'[br]*100 <= 100) && ('Table'[br]*100 >= 5), "GOOD ALERT"
)
)