gpt4 book ai didi

powerbi - 查询中无法识别电源双开关

转载 作者:行者123 更新时间:2023-12-02 20:26:36 27 4
gpt4 key购买 nike

已使用以下代码创建自定义列,但它卡在无法识别 SWITCH 函数的表达式错误处:

= Table.AddColumn(#"Removed Columns", "Empolyees", each SWITCH([Index],  
1, Empolyees = "Chris1",
2, Empolyees = "Chris2",
3, Empolyees = "Chris3",
4, Empolyees = "Chris4",
5, Empolyees = "Chris5",
6, Empolyees = "Chris6",
7, Empolyees = "Chris7",
8, Empolyees = "Chris8",
BLANK()
))

我试过删除引号,更改列名但都无济于事。请指教。提前致谢!

最佳答案

你搞混了 M and DAX .它们是两种不同的语言,都用于 Power BI。 SWITCH()是 DAX 函数,因此不能在您编写的 M 查询 中使用。

您可以用 if-then-else expression 替换 SWITCH 逻辑在 M 中:

= Table.AddColumn(#"Removed Columns", "Employees", each if [Index] = 1 then "Chris1" else if [Index] = 2 then "Chris2" else if [Index] = 3 then "Chris3" else if [Index] = 4 then "Chris4" else if [Index] = 5 then "Chris5" else if [Index] = 6 then "Chris6" else if [Index] = 7 then "Chris7" else if [Index] = 8 then "Chris8" else "")

result

具体看你想实现什么,也可以使用其他函数,但我暂时保持这种方式,而不是做假设。

关于powerbi - 查询中无法识别电源双开关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49720565/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com