powerbi - 使用switch作为嵌套comaprison的Dax错误
问题描述
嗨,我正在尝试根据两个度量值获得最后一列,我正在使用 Power BI,但我是新手。这是公式。我收到一个错误“功能开关不支持将真/假类型的值与文本类型的值进行比较”
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"))
解决方案
您会收到该错误,因为您有一些放错位置的括号,其中包含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"
)
)
推荐阅读
- c - 当变量在结构中的结构中时如何使用container_of()?
- python - 获取不包含另一个列表中元素的元素列表
- dji-sdk - 矩阵 300 RTK:两个流同时
- angular - 带过滤器的角度拖放
- ios - 如何通过单击 SwiftUI 中的按钮进入视图
- javascript - 是否有 ESLint 规则建议使用 a?.b?.c 而不是 abc 以避免一些错误
- cron - cron 调度程序如何在调度机制是轮询的分片持久存储之外进行扩展?
- excel - 连接两列 VBA。如果最后一行中的数据自动更新,我需要获取行中的连接值
- python - 如何一个接一个地运行多个不和谐令牌,直到它在 discord.py 中发送 X 条消息?
- sql - PostgreSQL:从 json 格式的字段中选择