powerbi - Power Bi 自定义列功能
问题描述
在 MQuery 中,我正在尝试创建一个自定义列。如果另一列的值介于 1 到 5 之间,则新列中的值将是一些文本。它给了我一个 Token Else 预期错误。
=if[#"Chair Independence Level"] = "1" then "Same Product Line"
else if[#"Chair Independence Level"]= "2" then "Different Product Line"
else if[#"Chair Independence Level"]= "3" then "Different Business Area"
else if[#"Chair Independence Level"]= "4" then "Different Sector"
else if [#"Chair Independence Level"]= "5" then "Not an Employee"
有谁知道如何解决问题或我应该将代码更改为什么?
解决方案
Power 查询中的 IF 条件需要使用 ELSE 语句来限制。只需添加 ELSE 就可以了:
=if[#"Chair Independence Level"] = "1" then "Same Product Line"
else if[#"Chair Independence Level"]= "2" then "Different Product Line"
else if[#"Chair Independence Level"]= "3" then "Different Business Area"
else if[#"Chair Independence Level"]= "4" then "Different Sector"
else if [#"Chair Independence Level"]= "5" then "Not an Employee"
else "NA"
如果 #"Chair Independence Level" 字段是数字,则:
=if[#"Chair Independence Level"] = 1 then "Same Product Line"
else if[#"Chair Independence Level"]= 2 then "Different Product Line"
else if[#"Chair Independence Level"]= 3 then "Different Business Area"
else if[#"Chair Independence Level"]= 4 then "Different Sector"
else if [#"Chair Independence Level"]= 5 then "Not an Employee"
else "NA"
推荐阅读
- elasticsearch - elasticSearch python API:put_mapping时出错
- java - 在特定视图上滑动时禁用 ViewPager 滑动
- java - 关于将变量声明为静态与非静态的最佳实践
- xml - Endless loop when read .xml-file
- r - 在 formattable (R) 中使用逗号函数
- c++ - 如何使用 FBX SDK 在 fbx 文件中加载嵌入的纹理?
- php - 有什么区别 where Employee::query()->where('id','=',9074)->get(); 和 Employee::query()->where('id',9074)->get();
- javascript - 要求用户在移动浏览器中获取当前位置
- typo3 - 如何在 TYPO3 9.5.7 中正确设置语言后备?
- multithreading - 如果正在运行,则终止分离的线程